Answers for "mongodb find and replace all"

0

mongo change all documents on field

//Update all documents with "oldName" to "newName"
db.names.updateMany({ "name": "oldName" }, {  $set: { "name" : "newName" }  })
Posted by: Guest on June-01-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 "mongodb find and replace all"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language