如何从MongoDb获取对象

时间:2016-07-04 11:23:35

标签: mongodb

I want to get result where secondaryParents = 1000004. How we can achive this.

{
    "_id" : ObjectId("577a151859defb33c0f8bf4a"),
    "_class" : "com.nv.tracker.db.model.User",
    "parentId" : NumberLong(1000004),
    "userId" : NumberLong(1000005),
    "firstName" : "Pranav",
    "lastName" : "Rathore",
    "addr" : {
        "address" : "",
        "landmark" : "",
        "city" : "",
        "state" : "",
        "country" : ""
    },
    "email" : "ashish.dubey@newvisionsoftware.in",
    "mobile" : "7879066069",
    "createdDate" : ISODate("2016-07-04T07:49:44.000Z"),
    "activeStatus" : false,
    "imagePath" : "http://172.20.0.210:8080/nvtracker/rest/resource/image/1000005",
    "deviceId" : "78 79 066069",
    "isSuperUser" : false,
    "dob" : "1468348200000",
    "checkAndriodOrIos" : 0,
    "isLogin" : false,
    "otp" : 0,
    "batteryLevel" : 30,
    "locationInterval" : 60,
    "deviceSpeed" : 45,
    "primaryMobile" : "9039101994",
    "secondaryMobile1" : "9039101994",
    "secondaryMobile2" : "",
    "primaryEmail" : "ashish.dubey@newvisionsoftware.in",
    "secondaryEmail1" : "abb@hh.con",
    "secondaryEmail2" : "",
    "isVerified" : false,
    "currentBatteryLevel" : 0,
    "currentSpeed" : 0,
    "subscriptionExpDate" : NumberLong(1498132426000),
    "enableNotification" : 1,
    "enableTakeOffAlert" : 0,
    "deleted" : false,
    "hasExternalDevice" : false,
    "secondaryParents" : {
        "1000003" : {
            "secondaryparentId" : NumberLong(1000003),
            "varifiedDate" : NumberLong(0),
            "addedDate" : NumberLong(1467628679286),
            "secreteCode" : "18716"
        },
       "1000004" : {
            "secondaryparentId" : NumberLong(1000004),
            "varifiedDate" : NumberLong(0),
            "addedDate" : NumberLong(1467628679286),
            "secreteCode" : "18716"
        }
    }
}

I want to get result where secondaryParents = 1000004. 

我们如何能够实现这一目标,我希望得到的结果是secondaryParents = 1000004.我们如何才能实现这一目标, 我想得到secondaryParents = 1000004的结果。 我们如何才能实现这一点。

I want to get result where secondaryParents = 1000004. 

我们如何能够实现这一目标,我希望得到的结果是secondaryParents = 1000004.我们如何才能实现这一目标, 我想得到secondaryParents = 1000004的结果。 我们如何才能实现这一点。

1 个答案:

答案 0 :(得分:0)

db.parents.find({"secondaryParents.1000004" : {$exists : true}})