次のドキュメントのコレクションがあります。
{
"_id" : ObjectId("56cbf9cd75de3ee9057b23c7"),
"title" : "Abc",
"comments" : [
{
"_id" : "",
"message" : "",
"active" : 1,
"status" : 1,
},
{
"_id" : "",
"message" : "",
"active" : 0,
"status" : 1,
},
{
"_id" : "",
"message" : "",
"active" : 1,
"status" : 1,
}
],
}
{
"_id" : ObjectId("553744ae75de3eb9128b4568"),
"title" : "Jhon",
"comments" : [
{
"_id" : "",
"message" : "",
"active" : 1,
"status" : 1,
}
]
}
コメントのすべてのステータスを0として更新する必要があります。ここで、comments.active=1です。以下のように解決しようとしましたが、コメントの最初のレコードのみが更新されます。私を助けてください..
db.comments.update({'comments.active':1},{$set:{'comments.$.status':0}})