From cf34d891b349b8bb799393067a77fa23a4874ad5 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Thu, 25 Jun 2020 11:25:16 +0300 Subject: fix: provide default value of 0 to votes amount --- hooks/convertPoll.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 => { { $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 }); -- cgit v1.2.3