aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2020-06-25 11:53:21 +0300
committereug-vs <eug-vs@keemail.me>2020-06-25 11:53:21 +0300
commita9678b794758164a86a8c136c1d8acc8b1d0135d (patch)
tree227a72f40a5de620604154221e2a3253f063da97
parentcf34d891b349b8bb799393067a77fa23a4874ad5 (diff)
downloadwhich-api-a9678b794758164a86a8c136c1d8acc8b1d0135d.tar.gz
fix: add userChoice correctly
-rw-r--r--hooks/convertPoll.ts4
1 files changed, 3 insertions, 1 deletions
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<HookContext> => {
{ 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']),