Answers for "replace a single string in a document mongodb"

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

mongodb replace string

db.mycollection.find({}).forEach((doc, index) => {
  doc.myStr = doc.myStr.replace('foo', 'bar');
  db.mycollection.save(doc);
});
Posted by: Guest on December-19-2020

Code answers related to "replace a single string in a document mongodb"

Code answers related to "Javascript"

Browse Popular Code Answers by Language