Created
May 29, 2013 16:04
-
-
Save johntron/5671463 to your computer and use it in GitHub Desktop.
For a collection of subdocuments, adds a human-friendly date string using an existing timestamp
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
var coll = '101.google.youtube'; | |
var r = db[coll].find({"$where": "typeof this.statistics_log != 'undefined' && this.statistics_log.length > 0"}); | |
while (r.hasNext()) { | |
var d = r.next(); | |
for(var i = 0, j = d.statistics_log.length; i < j; i++) { | |
var execute_at = new Date(d.statistics_log[i].execute_at_ts * 1000); | |
d.statistics_log[i].execute_at = execute_at.toString(); | |
} | |
print(db[coll].update({"_id": d._id}, d)); | |
} | |
// Run from command line with: mongo warehouse add_date_strings.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment