I want to make an update query for multiple subdocuments at once. I will be setting all the subdocuments statuses to passive where they satisfy the condition I give on query. <
Use method UpdateMany()
to update documents. According to framework and langauage this method will be different like Update({multi : true});
or UpdateAll({});`
For example :
db.collection.updateMany(
,
);
Use $set
to write.
Ref: https://docs.mongodb.com/v3.2/reference/method/db.collection.updateMany/
try {
db.restaurant.updateMany(
{ $or: []
},
{ $set: { "DeviceVersionPairs.$.Status": "passive" } }
);
} catch (e) {
print(e);
}