MongoDB查询嵌套数组

时间:2017-10-04 15:48:46

标签: mongodb

我有一个包含以下文档的MongoDB集合:

"_id" : "d0888171-473d-46c7-a9c2-e18dfa141998",
"NUMBER" : 111111,
"SECURITIES" : [ 
    {
        "FK_GROUPS_ID" : ObjectId("59d4e02540b8f85428c827f9"),
        "ACCESS_LEVEL" : "r"
    }, 
    {
        "FK_GROUPS_ID" : ObjectId("59d24bce184fcd62968a21a3"),
        "ACCESS_LEVEL" : "rw"
    }
]

}

如何在SECURITIES数组中查找具有特定FK_GROUPS_ID的所有文档?

由于

1 个答案:

答案 0 :(得分:0)

db.collection.find({'SECURITIES.FK_GROUPS_ID' : ObjectId("GroupsIdString")});