Created
February 20, 2016 21:59
-
-
Save ernestohs/95ef3d11ce393a6c85a7 to your computer and use it in GitHub Desktop.
MongoDB (function): Convert a field from String to Date
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
db.MyCollection.find({ MyFieldDate: { $type: 'string' }}).forEach(function (item) { | |
item.MyFieldDate = new Date(item.MyFieldDate); | |
db.MyCollection.save(item); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment