I have Dates in one Collection that were inserted incorrectly, and are in a simple "2015-09-10"
string format.
I'd like to update them to correct ISO Date format.
I've tried looping through Mongo with forEach()
but I don't know the shell well enough on how to update each document in the collection.
So far I'm at this point:
db.getCollection('schedules').find({}).forEach(function (doc) {
doc.time = new Date( doc.time ).toUTCString();
printjson( doc.time );
// ^ This just prints "Invalid Date"
// Also none of the below work when I try saving them
//doc.save();
//db.getCollection('schedules').save(doc);
});
What's missing here?