Skip to content

Commit 699be58

Browse files
committed
feat: query profile by username
1 parent ef5666b commit 699be58

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

services/profiles/profiles.class.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
import { Application } from '@feathersjs/express';
22
import { Params } from '@feathersjs/feathers';
3-
import { Poll } from 'which-types';
3+
import { Poll, User } from 'which-types';
44

55

66
export default class Profiles {
77
app!: Application;
88

9-
async get(id: string, params: Params): Promise<Poll[]> {
9+
async get(username: string, params: Params): Promise<Poll[]> {
10+
const profileUser = await this.app.service('users').find({
11+
query: { username }
12+
}).then((results: User[]) => results[0]);
13+
1014
return this.app.service('polls').find({
1115
...params,
1216
query: {
13-
authorId: id
17+
authorId: profileUser._id
1418
}
1519
});
1620
}

0 commit comments

Comments
 (0)