Skip to content

Commit d7d65bb

Browse files
committed
refactor: simplify profile service
1 parent 7c2d12b commit d7d65bb

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed
Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1-
import { PollSchema } from '../../models/polls/poll.schema';
2-
import PollModel from '../../models/polls/poll.model';
1+
import { Application } from '@feathersjs/express';
2+
import { Poll } from 'which-types';
3+
34

45
export default class Profiles {
5-
async get(id: string): Promise<PollSchema[]> {
6-
return PollModel.find({ authorId: id }).lean();
6+
app!: Application;
7+
8+
async get(id: string): Promise<Poll[]> {
9+
return this.app.service('polls').find({
10+
query: {
11+
authorId: id
12+
}
13+
});
14+
}
15+
16+
setup (app: Application) {
17+
this.app = app;
718
}
819
}
920

services/profiles/profiles.hooks.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import { Application } from '@feathersjs/express';
22
import Profiles from './profiles.class';
33

4-
import hooks from './profiles.hooks';
5-
64
export default (app: Application): void => {
75
app.use('/profiles', new Profiles());
8-
app.service('profiles').hooks(hooks);
96
};
107

0 commit comments

Comments
 (0)