I have objects that use the keys updated_at and created_at which have string timestamps like 2012-08-29T16:04:34-04:00. I'm inserting this into MongoDB. The catch is each object can have a variable number of instances of updated_at and created_at (they are in arrays within). Is there any code out there that can be used to search an array for updated_at and created_at and replace the values with $.created_at = new Date($.created_at)?
{
"name":"thomas",
"created_at":"2012-08-29T16:04:34-04:00",
"updated_at":"2012-08-29T16:04:34-04:00",
"logs":[
{
"something":"something",
"created_at":"2012-08-29T16:04:34-04:00",
},
{
"something":"something",
"created_at":"2012-08-29T16:04:34-04:00",
},
]
}
to
{
"name":"thomas",
"created_at":new Date("2012-08-29T16:04:34-04:00"),
"updated_at":new Date("2012-08-29T16:04:34-04:00"),
"logs":[
{
"something":"something",
"created_at":new Date("2012-08-29T16:04:34-04:00"),
},
{
"something":"something",
"created_at":new Date("2012-08-29T16:04:34-04:00"),
},
]
}