Yog*_*oga 3 mongodb mongodb-query aggregation-framework
如何$in在mongoDB中与聚合一起编写查询?我想为下面的SQL写一个等效的mongoDB查询
SELECT name,count(something) from collection1
where name in (<<list of Array>>) and cond1 = 'false'
group by name
Run Code Online (Sandbox Code Playgroud)
等效的mongo查询如下:
db.collection1.aggregate([
{ "$match": {
"name": { "$in": arrayList },
"cond1": "false"
} },
{ "$group": {
"_id": "$name",
"count": { "$sum": "$something" }
} }
])
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4136 次 |
| 最近记录: |