如何查询下面的文件,找到所有ev = 1

时间:2016-03-10 10:21:40

标签: mongodb mongodb-query aggregation-framework

我想在下面的文档中查询以查找email_info子集的所有ev

{ 
    "_id" : ObjectId("56e13dc9abdb1c233db92dff"), 
    "customer_id" : NumberInt(8383), 
    "customerdetails" : {
        "name" : "Myth 2016", 
        "email_info" : {
            "email" : "myth1926@gmail.com", 
            "ev" : NumberInt(1)
        }, 
        "mobile_userid" : "3#102103293090775998087", 
        "usertype" : "non-anon", 
        "loginmode" : "GooglePlus"
    }
}

我正在使用

db.customer_detail.find({"email_info.ev":1});

但它没有给我结果。

1 个答案:

答案 0 :(得分:4)

您必须包含所有路径:

db.customer_detail.find({"customerdetails.email_info.ev":1});