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" } }
);