I Want to count "winStatus" 3 times by condition LOSS, Win and Pending.
gameBids.aggregate([
{
$group : {
_id: "$userId",
countBids : { $sum : 1 },
winCount : { $sum : { $cond: { }}},
loseCount : { $sum : { $cond: { }}},
pendingCount : { $sum : { $cond: { }}},
sumbiddingPoints : { $sum: '$biddingPoints'},
sumWinPoint : { $sum: '$gameWinPoints'}
}
}
], function (error, group) {
if (error) throw error;
else res.json(group);
});
how this can be done ?