Here's what it looks like -
db.log.aggregate({
$match:{ v:1, t:"trainingStep" },
$group:{ _id:{userId:'$u',questionId:'$s'}, counts:{$sum:1} },
$match:{ 'counts':{$gte:2} }
})
I've tried 'counts', '$counts', "$counts"... but none did the trick!
Each of the operators in your aggregate
pipeline need to be separate objects. Also, while some versions of the shell (and drivers) may allow passing the objects as separate parameters, the correct way is to pass them wrapped in a single array. Try this instead:
db.log.aggregate([
{ $match: { v: 1, t: "trainingStep" } },
{ $group: { _id: {userId: '$u', questionId: '$s'}, counts: {$sum: 1} } },
{ $match: { 'counts': {$gte: 2} } }
])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With