Skip to content

Commit fc9cf3b

Browse files
committed
feat!: construct VoteService based on VoteModel
1 parent ffcb9d2 commit fc9cf3b

File tree

3 files changed

+6
-24
lines changed

3 files changed

+6
-24
lines changed

models/polls/poll.schema.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { Document, Schema, Types } from 'mongoose';
22

33
export interface ImageDataSchema {
44
url: string;
5-
votes: string[];
65
}
76

87
export interface PollSchema extends Document {
@@ -17,12 +16,6 @@ export interface PollSchema extends Document {
1716

1817
export const imageDataSchema = {
1918
url: String,
20-
votes: [
21-
{
22-
type: Types.ObjectId,
23-
ref: 'vote'
24-
}
25-
]
2619
};
2720

2821
export const pollSchema = new Schema({

services/votes/votes.class.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

services/votes/votes.service.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import { Application } from '@feathersjs/express';
2-
import Votes from './votes.class';
2+
import service from 'feathers-mongoose';
3+
import Model from '../../models/votes/vote.model';
34

45
import hooks from './votes.hooks';
56

7+
const VoteService = service({ Model });
8+
69
export default (app: Application): void => {
7-
app.use('/polls/:id/votes/', new Votes());
8-
app.service('/polls/:id/votes/').hooks(hooks);
10+
app.use('/votes/', VoteService);
11+
app.service('votes').hooks(hooks);
912
};
1013

0 commit comments

Comments
 (0)