From d7d65bbde562519f6a78d90b8ca11a3bdd0420a1 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sat, 27 Jun 2020 01:24:25 +0300 Subject: refactor: simplify profile service --- services/profiles/profiles.class.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'services/profiles/profiles.class.ts') diff --git a/services/profiles/profiles.class.ts b/services/profiles/profiles.class.ts index 52d6b47..564e2a6 100644 --- a/services/profiles/profiles.class.ts +++ b/services/profiles/profiles.class.ts @@ -1,9 +1,20 @@ -import { PollSchema } from '../../models/polls/poll.schema'; -import PollModel from '../../models/polls/poll.model'; +import { Application } from '@feathersjs/express'; +import { Poll } from 'which-types'; + export default class Profiles { - async get(id: string): Promise { - return PollModel.find({ authorId: id }).lean(); + app!: Application; + + async get(id: string): Promise { + return this.app.service('polls').find({ + query: { + authorId: id + } + }); + } + + setup (app: Application) { + this.app = app; } } -- cgit v1.2.3 From a8c74bf2c5b8a8cc0bfd0f1d082eb3bf8357f6bc Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sat, 27 Jun 2020 01:26:03 +0300 Subject: style: fix linting errors --- services/profiles/profiles.class.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'services/profiles/profiles.class.ts') diff --git a/services/profiles/profiles.class.ts b/services/profiles/profiles.class.ts index 564e2a6..3461cbc 100644 --- a/services/profiles/profiles.class.ts +++ b/services/profiles/profiles.class.ts @@ -13,7 +13,7 @@ export default class Profiles { }); } - setup (app: Application) { + setup(app: Application): void { this.app = app; } } -- cgit v1.2.3