try{
Staff.aggregate(
{$group:{_id:{name:"$name",age:'$age'},total:{$sum:1}}},
{$match:{total:{$gt:1}}}
, modelHelper.mergeStaffCallBack);
}catch (err) {
console.log(err);
}
This is the equivalent query in mongoshell.
db.staffs.aggregate([
{
$group:{
_id:{name:"$name",age:'$age'},
total:{$sum:1}
}
},
{
$match:{
total:{ $gt: 1 }
}
}
]);
It executed successfully. I cannot spot the error in my nodejs code above. The catch caught the error
"Error: Arguments must be aggregate pipeline operators".
Can someone enlighten me?
Aucun commentaire:
Enregistrer un commentaire