mongoDB嵌套查询
文档如下:
{
"_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}})