如何获取城市是班加罗尔的数据,在mogodata

时间:2017-11-22 08:06:59

标签: arrays database mongodb nosql

请找到以下数据: -

{
    "_id" : ObjectId("5a15262a0a2680e91343be0a"),
    "name" : "abhi",
    "mobile" : 8888888888.0,
    "addrs" : "['street'=>'knt','city'=>'bangalore']"
}

1 个答案:

答案 0 :(得分:2)

我会将字符串的'addrs'字段更改为:

{ 
    "_id" : ObjectId("5a15262a0a2680e91343be0a"), 
    "name" : "abhi", 
    "mobile" : 8888888888.0, 
    "addrs" : {
        "street" : "knt", 
        "city" : "bangalore"
    }
}

并搜索:

{"addrs.city":"bangalore"}