MongoDB remplacer la chaîne
db.mycollection.find({}).forEach((doc, index) => {
doc.myStr = doc.myStr.replace('foo', 'bar');
db.mycollection.save(doc);
});
garzj
db.mycollection.find({}).forEach((doc, index) => {
doc.myStr = doc.myStr.replace('foo', 'bar');
db.mycollection.save(doc);
});
try {
db.restaurant.replaceOne(
{ "name" : "Central Perk Cafe" },
{ "name" : "Central Pork Cafe", "Borough" : "Manhattan" }
);
} catch (e){
print(e);
}