Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import Poll from '../models/poll.model'
export function create(data) {
return Poll.create(data)
export function findAll() {
return Poll.find().sort({ createdAt: -1 })
export function voteOnPoll(optionId) {
return Poll.findOneAndUpdate({
'options._id': optionId,
}, {
$inc: {
'options.$.votes': 1,
}, {
new: true,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.