mongoDB内嵌文档返回匹配的数组元素
2021/8/21 2:07:41
本文主要是介绍mongoDB内嵌文档返回匹配的数组元素,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
使用$unwind
,用于分割内嵌数组
适合情况:条件不唯一,查询多个
例子:
db.collection.aggregate([{'$unwind': '$arr1'}, {'$unwind': '$arr1.arr2'}, {'$match': {'arr1.arr2.field': 'value'}}])
处理多重嵌套的基本思路:提取、拆分、匹配
这篇关于mongoDB内嵌文档返回匹配的数组元素的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-06-26解决google chrome helper 内存占用较高!
- 2024-04-01got an unexpected keyword argument
- 2024-03-30维多利亚的秘密 golang入坑系统
- 2024-03-29mongodb sort by date
- 2024-03-29go swagger
- 2024-03-25mongodb cdc
- 2024-03-25how to use go in vscode
- 2024-03-22mongooseserverselectionerror: connect econnrefused ::1:27017
- 2024-03-21pymongo insert_many
- 2024-03-18projection mongodb