我有这个文件:
{
"_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
。我该怎么办?