I have a field
"data" : {
"user" : "derp",
"id" : "xHOSTNAME_xderp"
I want to replace all docs with xHOSTNAME_* to yHOSTNAME_. Any idea how to search and replace. I've seen some other posts similarly related but none seemed to work.
db.test1.find().forEach(function(doc) {
doc.data.id = doc.data.id.replace('xHOSTNAME_', 'yHOSTNAME_');
db.test1.save(doc);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With