Skip to content

Instantly share code, notes, and snippets.

@stephanie-gredell
Created April 8, 2015 23:18
Show Gist options
  • Save stephanie-gredell/23d2856926cdebcab453 to your computer and use it in GitHub Desktop.
Save stephanie-gredell/23d2856926cdebcab453 to your computer and use it in GitHub Desktop.
Mongo Search & Replace
var cursor = db.collection.find(url: /http/)
while (cursor.hasNext()) {
var x = cursor.next();
print("Before: "+x['url']);
x['url'] = x['url'].replace('http', 'https');
print("After: "+x['url']);
db.collection.update({_id : x._id}, x);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment