I am trying to use $condconditionally $pushmultiple integers in an array of numbers during an aggregate $groupwithout any success. Here is my code:
Item.aggregate(
[
{
$group: {
_id: "$_id",
numbers: {
$push: {
$cond: {
if: { $gt: [ "$price.percent", 70 ] },
then: { $each: [10,25,50,70] },
else: null,
}
}
}
}
},
]
)
...
Is Mongo DB just not configured for this right now, or am I looking at it all wrong?
source
share