blob: 0490b7e16f1ad3df99301c2edd4df96f67895235 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
import PollModel from '../../models/polls/poll.model';
import { PollSchema } from '../../models/polls/poll.schema';
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);
return poll.save();
}
return null;
}
}
|