How does mongodb batch modify the properties of embedded documents?

  mongodb, question
{
 "_id" : ObjectId("52fb2ceb1e2f8622d4228a7a"),
 "from" : 0,
 "message" : [{
 "data" : "test1",
 "status" : true,
 "time" : 1
 }, {
 "data" : "test2",
 "status" : true,
 "time" : 2
 }],
 "to" : 1,
 "type" : "s"
 }

How to use a command to change the status attribute in two object elements in the message array to false?

Whether logical processing can only be done at the client:

var cursor =  db.msg.find({“to”: uid, “message.status”: false});
 While(cursor.hasNext()){ // since the cursor obtained by find has been snapshot by default, it will not affect the data added after find in theory
 var doc = cursor.next();
 var from = doc.from;
 var type = doc.type;
 //Loop all elements in the message array of the corresponding document to make line-by-line changes
 item.message.foreach(function(msg){
 db.msg.update({
 “to”: uid,
 “from”: from,
 “type”: type,
 “message.time”: msg.time
 },
 {
 “$set”: {
 “message.$.status”: true
 }
 }
 );
 });
 }

Please correct me ~ ~

var true_metadata = db.modulestore.find({"metadata.tabs": {$exists: true}})
 var updated_tabs = [];
 
 true_metadata.forEach(function(item){
 var tabs = item.metadata.tabs
 if (item && item.metadata && tabs ){
 tabs.forEach(function(item){
 if(item.type == "wiki") {
 Name = "information";
 }
 })
 
 db.modulestore.update({"_id": item._id}, {$set: {
 "metadata.tabs": tabs
 }})
 
 updated_tabs.push(tabs)
 }
 })
 
 updated_tabs

I also encountered a similar problem. I checked the official documents. My local solution is as above. I hope I can help you