Answers for "mongodb query to replace value of all documents"

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 query to replace value of all documents"

Code answers related to "Javascript"

Browse Popular Code Answers by Language