Mongo db - 查询嵌套数组和对象 [英] Mongo db - Querying nested array and objects
本文介绍了Mongo db - 查询嵌套数组和对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下文档结构:
{
"_id":"12345",
"value":{
"T":0,
"v":[
{
"name":"JW",
"cost":100
}
]
}
}
如何查询姓名键?我尝试了点符号但没有运气(我认为它只适用于两个级别)
How do I query the name key? I tried the dot notation but without luck (I think it works for only two levels)
推荐答案
目前还不清楚您到底尝试了什么,但这应该可以通过 name
找到上述文档:
It's not clear exactly what you tried, but this should work to find the above doc by name
:
db.collection.find({ "value.v.name": "JW" })
这篇关于Mongo db - 查询嵌套数组和对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文