Thuta Learning
MongoDB
IntermediateData & DatabasesIntermediate

Update Many Documents

MongoDBLesson 12

To update every document that matches a filter, use the updateMany() method.

javascript
db.inventory.updateMany(
   { qty: { $lt: 50 } },
   {
     $set: { "status": "low" }
   }
)
You should see
(Every document with qty below 50 will get a new field: status: "low")

Updated on

Progress is saved only in this browser on this device. It isn't synced to other devices.

Report a problem with this lessonOpens your email app with this lesson's address filled in — nothing is sent until you send it.

Update Many Documents | Thuta Learning