Created
September 20, 2011 07:37
-
-
Save jeffreyiacono/1228573 to your computer and use it in GitHub Desktop.
(budget) find / replace for mongodb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For a collection "things" that has multiple documents of the form: | |
// { "_id" : ObjectId("4e5c47d1b0207a1ad3000001"), | |
// "filename" : "uploads/development/user/4dbf2b0ab0207a2e8a000001/avatar/avatar.png", | |
// "other_data" : "foo" | |
// }, etc. | |
// we want to replace "development" in "filename" with "production". | |
// Run via mongo shell: | |
db.things.find().forEach(function(e) { | |
var parts = e.filename.split('development'); | |
e.filename = parts[0] + 'production' + parts[1]; | |
db.things.save(e); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment