aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2020-08-10 12:50:08 +0300
committereug-vs <eug-vs@keemail.me>2020-08-10 13:57:46 +0300
commit699be5814bc378fcb09dbe8eadadaf3022926a24 (patch)
tree865c56fd7ccb323f81d8608d9cdd446ab456c62b
parentef5666b96e971254c112458f39cfd9b329080bf0 (diff)
downloadwhich-api-699be5814bc378fcb09dbe8eadadaf3022926a24.tar.gz
feat: query profile by username
-rw-r--r--services/profiles/profiles.class.ts10
1 files 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<Poll[]> {
+ async get(username: string, params: Params): Promise<Poll[]> {
+ 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
}
});
}