diff options
Diffstat (limited to 'services/votes/votes.class.ts')
| -rw-r--r-- | services/votes/votes.class.ts | 14 | 
1 files changed, 14 insertions, 0 deletions
| diff --git a/services/votes/votes.class.ts b/services/votes/votes.class.ts new file mode 100644 index 0000000..d95c148 --- /dev/null +++ b/services/votes/votes.class.ts @@ -0,0 +1,14 @@ +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> { +    return PollModel.findById(params.route.id) +      .then(poll => poll?.vote(params.user._id, data.which)) +      .catch(e => { +        console.error(e); +        return null; +      }); +  } +} + | 
