db.mycollection.find({}).forEach((doc, index) => { doc.myStr = doc.myStr.replace('foo', 'bar'); db.mycollection.save(doc); });