Created
March 5, 2011 01:30
-
-
Save tony4d/856009 to your computer and use it in GitHub Desktop.
Simple way to change data in mongo using existing data in a document
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
// Here my collection is named articles | |
// I'm changing the blog_name field in every document in that collection to lowercase | |
db.articles.find().forEach(function(doc){if(typeof(doc.blog_name) == 'string') {doc.blog_name = doc.blog_name.toLowerCase(); db.articles.save(doc); }}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment