mongdb操作

item中的数组更新

db.test2.insert(
{
"content" : "this is a blog post.",
"comments" :
[
{
"author" : "Mike",
"comment" : "I think that blah blah blah...",
},
{
"author" : "John",
"comment" : "I disagree."
}
]
}
);

//查找名为Mike的记录,并且该人的名字改成tank
db.test2.update( { "comments.author": "Mike"},
{ $set: { "comments.$.author" : "tank" } }
);

posted @ 2017-11-12 21:07  人微言轻1  阅读(107)  评论(0编辑  收藏  举报