Created
March 20, 2015 09:19
-
-
Save karantir/b00bfb5a0eac483f9168 to your computer and use it in GitHub Desktop.
Cast date type on specific field for all documents in mongodb collection
This file contains hidden or 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
var cursor = db.<collection>.find(); | |
while (cursor.hasNext()) { | |
var doc = cursor.next(); | |
db.<collection>.update({_id : doc._id}, { $set : { <field>: new Date(doc.<field>)} }) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment