Answers for "replace the document to update mongo"

1

mongodb replace document

try {
   db.restaurant.replaceOne(
      { "name" : "Central Perk Cafe" },
      { "name" : "Central Pork Cafe", "Borough" : "Manhattan" }
   );
} catch (e){
   print(e);
}
Posted by: Guest on August-29-2020
0

how to update subdocument mongodb

db.getCollection('products')
.update({"reviews.user": ObjectId("5f6e2e0b70eb0208fc8401a1")}, 
{$set: {"reviews.$.rating": NumberInt(3)}})
Posted by: Guest on September-26-2020

Code answers related to "replace the document to update mongo"

Code answers related to "Javascript"

Browse Popular Code Answers by Language