CRUD Operations in MongoDB / Perform CRUD Operations
Updating MongoDB Documents by Using updateMany()
To update multiple documents, use the updateMany()
method. This method accepts a filter document, an update document, and an optional options object. The following code shows an example:
db.books.updateMany(
{ publishedDate: { $lt: new Date("2019-01-01") } },
{ $set: { status: "LEGACY" } }
)