diff options
author | eug-vs <eug-vs@keemail.me> | 2020-06-25 11:25:16 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2020-06-25 11:25:16 +0300 |
commit | cf34d891b349b8bb799393067a77fa23a4874ad5 (patch) | |
tree | 0b7e864d829d1f74cf31097828d693e094a2be4a | |
parent | a58354a1d1bf967fc932723b9138d8c6322591d5 (diff) | |
download | which-api-cf34d891b349b8bb799393067a77fa23a4874ad5.tar.gz |
fix: provide default value of 0 to votes amount
-rw-r--r-- | hooks/convertPoll.ts | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/hooks/convertPoll.ts b/hooks/convertPoll.ts index b4f8376..4da25c1 100644 --- a/hooks/convertPoll.ts +++ b/hooks/convertPoll.ts @@ -19,7 +19,7 @@ export default async (context: HookContext): Promise<HookContext> => { { $group: { _id: '$which', total: { $sum: 1 } } } ]).then(groups => groups.reduce( (acc, group) => _.set(acc, group._id + '.votes', group.total), - {} + { left: { votes: 0 }, right: { votes: 0 } } )); const userChoice = await VoteModel.findOne({ pollId: poll._id, userId: user?._id }); |