diff options
Diffstat (limited to 'services/votes/votes.class.ts')
-rw-r--r-- | services/votes/votes.class.ts | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/services/votes/votes.class.ts b/services/votes/votes.class.ts index 6b9181b..3220ee7 100644 --- a/services/votes/votes.class.ts +++ b/services/votes/votes.class.ts @@ -5,11 +5,8 @@ export default class Votes { async create(data: any, params: any): Promise<PollSchema | null> { const poll = await PollModel.findById(params.route.id); if (poll) { - const which: 'left' | 'right' = data.which; - const { user } = params; - poll.contents[which].votes.push(user._id); - poll.save(); - return poll.toObject(); + const updatedPoll = await poll.vote(params.user._id, data.which); + return updatedPoll.toObject(); } return null; } |