I want to find a document based on key for nested object in mongoose. For example
{
"_id": 1,
"first_name": "Tom",
"email": "tom@example.com",
"ACL": {
123gd: {
read: true,
write: false,
},
3sg2w: {
read: true,
write: false,
}
}
},
{
"_id": 2,
"first_name": "Tom",
"email": "tom@example.com",
"ACL": {
546er: {
read: true,
write: false,
},
98trw: {
read: true,
write: false,
}
}
}
For the above sample document data i want write a method to find and return the document only having ACL key is 123gd
.
that is
{
"_id": 1,
"first_name": "Tom",
"email": "tom@example.com",
"ACL": {
123gd: {
read: true,
write: false,
},
3sg2w: {
read: true,
write: false,
}
}
}
So how can i write in mongoose to find the specific document