0
我正在下面的文件文檔中查找子元素MongoDB中
{
"_id" : 123344223,
"firstName" : "gopal",
"gopal" : [
{
"uuid" : "123",
"name" : "sugun",
"sudeep" : [
{
"uuid" : "add32",
"name" : "ssss"
},
{
"uuid" : "fdg456",
"name" : "gfg"
}
]
},
{
"uuid" : "222",
"name" : "kiran"
}
]
}
我想我的輸出如下
{
"_id" : 456,
"gopal" : [
{
"uuid" : "123",
"name" : "sugun",
"sudeep" : [
{
"uuid" : "add32",
"name" : "ssss"
}
]
}
]
}
,我試圖像
db.People.findOne({_id:123},{gopal:{$elemMatch:{uuid:"123",sudeep:{$elemMatch:{uuid:"add32"}}}}});
很多東西
但無論我嘗試它返回這樣的文件
{
"_id" : 123,
"gopal" : [
{
"uuid" : "123",
"name" : "sugun",
"sudeep" : [
{
"uuid" : "add32",
"name" : "ssss"
},
{
"uuid" : "fdg456",
"name" : "gfg"
}
]
}
]
}
你能幫忙嗎?
[只檢索對象數組中的查詢元素在MongoDB集合](http://stackoverflow.com/questions/3985214/retrieve-only-the-queried-element-in-an-object-array-in-mo ngodb收集) – styvane 2016-01-08 08:16:39