Created
February 17, 2013 21:06
-
-
Save jason-w/4973476 to your computer and use it in GitHub Desktop.
Convert document field type in 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
// list of $type values: http://docs.mongodb.org/manual/reference/operator/type/ | |
db.person.find( { 'integer_id' : { $type : 2 } } ).forEach( function (x) { | |
x.integer_id = new NumberLong(x.integer_id); // convert field to Long | |
db.person.save(x); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment