首页 > 解决方案 > MongoDB 嵌套对象

问题描述

我需要帮助。最近开始教mongodb。我不知道如何访问嵌套项目。请帮忙:我怎样才能找到“职业”的钥匙?

{
"_id" : ObjectId("60a4bbd1753b2bb53e6f7dba"),
"name" : "Bob",
"class" : 7.0,
"lessons" : [ 
    "english", 
    "mathematics"
],
"avgScore" : 3.5,
"parents" : [ 
    {
        "gender" : "female",
        "name" : "Ira"
    }, 
    {
        "gender" : "male",
        "name" : "Dima",
        "profession" : "programmer"
    }
]
}

标签: mongodb

解决方案


我认为您需要使用elemMatch ElemMatch


推荐阅读