Last active
February 7, 2017 14:13
-
-
Save faisal00813/d1e22d31aa7dbee956ae8c690ea1530c to your computer and use it in GitHub Desktop.
Query for updating the timesatamp in document extracted from _Id field
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
db['your-collection'].find().forEach(function (doc){ | |
d = doc._id.getTimestamp(); | |
doc.visitedOn = d; | |
db['your-collection'].update({"_id":doc._id},doc,{upsert:true}); | |
print(d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate() + " " + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds()) }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment