From 699be5814bc378fcb09dbe8eadadaf3022926a24 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Mon, 10 Aug 2020 12:50:08 +0300 Subject: feat: query profile by username --- services/profiles/profiles.class.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/services/profiles/profiles.class.ts b/services/profiles/profiles.class.ts index a6de474..f0e82c5 100644 --- a/services/profiles/profiles.class.ts +++ b/services/profiles/profiles.class.ts @@ -1,16 +1,20 @@ import { Application } from '@feathersjs/express'; import { Params } from '@feathersjs/feathers'; -import { Poll } from 'which-types'; +import { Poll, User } from 'which-types'; export default class Profiles { app!: Application; - async get(id: string, params: Params): Promise { + async get(username: string, params: Params): Promise { + const profileUser = await this.app.service('users').find({ + query: { username } + }).then((results: User[]) => results[0]); + return this.app.service('polls').find({ ...params, query: { - authorId: id + authorId: profileUser._id } }); } -- cgit v1.2.3