mongoDB嵌套查询

来源:互联网 发布:广发交易软件 编辑:程序博客网 时间:2024/05/17 00:52

文档如下:

{
        "_id" : ObjectId("578f2122774326567ca82dfe"),
        "person" : {
                "age" : 28,
                "name" : "liqing",
                "_type" : "person"
        }
}

现在需要查询person中age为28的

查询:

 db.test.find({"person.age":28})

或者:

db.test.find({"person":{"age":28,"name:"liqing","_type":"person"}})

现在需要把age修改为27

修改:

db.test.update({"person.age":28},{$set:{"person.age":27}})



0 0
原创粉丝点击