Answers for "updatemany mongodb"

3

mongo updatemany query

try {
   db.restaurant.updateMany(
      { violations: { $gt: 4 } },
      { $set: { "Review" : true } }
   );
} catch (e) {
   print(e);
}
Posted by: Guest on January-23-2021
4

mongodb update

db.collectionName.update({"aField":"vale1"},{$set:{"anotherField":"value2"}})

-search for documentations for more examples than search
-aField is used to find the documents
-anotherField is the field that will be updated
-You can also use the below:
-- updateOne
-- findOneAndUpdate
Posted by: Guest on December-12-2020
0

updatemany mongodb

db.collection.updateMany(filter, update, options)
Posted by: Guest on January-30-2021

Browse Popular Code Answers by Language