0
如何在mongoDB中編寫$in
查詢以及聚合?我想寫的SQL等效MongoDB的查詢下面
SELECT name,count(something) from collection1
where name in (<<list of Array>>) and cond1 = 'false'
group by name
如何在mongoDB中編寫$in
查詢以及聚合?我想寫的SQL等效MongoDB的查詢下面
SELECT name,count(something) from collection1
where name in (<<list of Array>>) and cond1 = 'false'
group by name
等效蒙戈查詢如下:
db.collection1.aggregate([
{ "$match": { "name": { "$in": arrayList } } },
{
"$group": {
"_id": "$name",
"count": { "$sum": "$something" }
}
}
])