Update multiple subdocument without exact sub document level condition
I have collection with the following document: { "_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, } ] } I need to update all status of comments as 0 where comments.active=1 . I tried to solve it as below, but only first record of the comments is