I am having mongodb data like this
{
"_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
}
I want to retrieve only View:true in UIList under UiName:"ManageFacility" 's how to retrieve that.
I tried to get the data following this query but it retrieve all UIList Under Uiname:,View,Edit value.
db.getCollection("manage_roles_news").find(
{ _id:ObjectId("58eb32fb58bbf720a80daf6f")},
{UIList: {$elemMatch: {UiName: "ManageFacility"}}});
How to retrieve that only view in UIlist under Uiname:"ManageFacility"
can anyone tell me
db.getCollection("manage_roles_news").find( { _id:ObjectId("58eb32fb58bbf720a80daf6f")}, {UIList: {$elemMatch: {UiName: "ManageFacility", View:true}}});