我有這樣的如何檢索選定陣列對象MongoDB中
{
"_id" : ObjectId("58eb32fb58bbf720a80daf6f"),
"RoleName" : "Admin",
"UIList" : [
{
"UiName" : "ManageRole",
"View" : true,
"Edit" : false,
"_id" : ObjectId("58eb32fb58bbf720a80daf79")
},
{
"UiName" : "ManageBuildings",
"View" : false,
"Edit" : false,
"_id" : ObjectId("58eb32fb58bbf720a80daf78")
},
{
"UiName" : "ManageFacility",
"View" : true,
"Edit" : false,
"_id" : ObjectId("58eb32fb58bbf720a80daf77")
}
],
"__v" : 0,
"Description" : "Full Control",
"IsActive" : true
}
MongoDB的數據我只想檢索查看:UiName下UIList真:「ManageFacility」的如何檢索。
我試圖得到這個查詢後面的數據,但它檢索Uiname下的所有UIList:,View,Edit值。
db.getCollection("manage_roles_news").find(
{ _id:ObjectId("58eb32fb58bbf720a80daf6f")},
{UIList: {$elemMatch: {UiName: "ManageFacility"}}});
如何檢索UIlist Uiname下,只有觀點:「ManageFacility」
誰能告訴我
嘗試'db.getCollection( 「manage_roles_news」)找到( {_id:物件( 「58eb32fb58bbf720a80daf6f」)},{ UIList:{$ elemMatch:{UiName: 「ManageFacility」,查看:真正} }});' – Veeram
嗨,@Veeram這個查詢也返回所有managefacility列 – Vinoth
我只想查看 – Vinoth