Node.js 对象数组内的更新标志
我收到了这份文件:Node.js 对象数组内的更新标志,node.js,mongodb,Node.js,Mongodb,我收到了这份文件: { "_id" : ObjectId("540d881d475d68010693e340"), "notes" : [ { "owner" : null, "creation" : 1411641315424, "text" : "test rec", "action" : "0", "recipients" : [
{
"_id" : ObjectId("540d881d475d68010693e340"),
"notes" : [
{
"owner" : null,
"creation" : 1411641315424,
"text" : "test rec",
"action" : "0",
"recipients" : [
{
"username" : "root",
"read" : false
},
{
"username" : "zivolof",
"read" : false
}
]
},
{
"owner" : null,
"creation" : 1411641315424,
"text" : "test rec",
"action" : "0",
"recipients" : [
{
"username" : "root",
"read" : false
},
{
"username" : "zivolof",
"read" : false
}
]
}
]
}
我通过以下查询找到它:
{
"_id": id,
"notes.recipients": {
$elemMatch: {
username: username,
read: false
}
}
}
然后我需要将整个文档的
read
标志更新为true
。我该怎么办?@FezVrasta新功能:坦斯克!所以目前还没有直接MongoDB查询的方法?