直接上例子: { "groups": { "a": [ { "id": 1, "status": "open" }, { "id": 2, "status": "open" }, { "id": 3, "status": "closed" } ], "b": [ { "id": 4, "status": "closed" }, { "id": 5, "status": "open" }, { "id": 6, "status": "closed" } ] } }
对这个数据,怎么实现类似 find({"groups.*.status": "closed"}) 这样的查询?
1
defunct9 2021-12-30 19:13:48 +08:00
.filter
|
2
shadow1949 2021-12-31 10:11:03 +08:00
unwind
|
3
galikeoy 2021-12-31 11:15:34 +08:00
objectToArray
unwind unwind 性能不好,建议拿数据到代码里操作 |