aboutsummaryrefslogtreecommitdiff
path: root/hooks
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2020-06-25 11:25:16 +0300
committereug-vs <eug-vs@keemail.me>2020-06-25 11:25:16 +0300
commitcf34d891b349b8bb799393067a77fa23a4874ad5 (patch)
tree0b7e864d829d1f74cf31097828d693e094a2be4a /hooks
parenta58354a1d1bf967fc932723b9138d8c6322591d5 (diff)
downloadwhich-api-cf34d891b349b8bb799393067a77fa23a4874ad5.tar.gz
fix: provide default value of 0 to votes amount
Diffstat (limited to 'hooks')
-rw-r--r--hooks/convertPoll.ts2
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 });