From a9678b794758164a86a8c136c1d8acc8b1d0135d Mon Sep 17 00:00:00 2001 From: eug-vs Date: Thu, 25 Jun 2020 11:53:21 +0300 Subject: fix: add userChoice correctly --- hooks/convertPoll.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hooks/convertPoll.ts b/hooks/convertPoll.ts index 4da25c1..1c32851 100644 --- a/hooks/convertPoll.ts +++ b/hooks/convertPoll.ts @@ -22,7 +22,9 @@ export default async (context: HookContext): Promise => { { left: { votes: 0 }, right: { votes: 0 } } )); - const userChoice = await VoteModel.findOne({ pollId: poll._id, userId: user?._id }); + const userChoice = await VoteModel.findOne( + { pollId: poll._id, userId: user?._id } + ).then(vote => vote?.which); return _.merge( _.omit(poll, ['authorId']), -- cgit v1.2.3