我想为mongoose中的嵌套对象查找一个基于键的文档.例如
{
"_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,
}
}
}
对于上面的示例文档数据,我想编写一个方法来查找并返回只有ACL key is 123gd
个的文档.
{
"_id": 1,
"first_name": "Tom",
"email": "tom@example.com",
"ACL": {
123gd: {
read: true,
write: false,
},
3sg2w: {
read: true,
write: false,
}
}
}
那么我怎样才能在mongoose中找到特定的文档呢