I know there are stackoverflow posts on updating mongodb sting date to iso date but i could not find how to do in nested field. my json structure is like this:
{
"_id" : "588885445",
"data" : {
"team" : "abc",
"subteam" : "123",
"datetime" : "2018-05-20 11:47:01",
}
}
i need to change date string to iso date. This is what I am trying but its not working.
var cursor = db.getCollection('log').find({}) ;
while (cursor.hasNext()) {
var doc = cursor.next();
db.members.update({_id : doc._id}, {'$set' : {"data.datetime" : new ISODate('data.datetime') }});
}