Anyone know it its possible to for a BSONDocument to apply full strict to shell mode conversion, as currently it only seems to convert _id and nothing else (such as dates) ?.
I want to do something like this ...
Lets say I have the following json in a JsValue. Its a JsValue because I'm using play and have some http request payload as a JsValue and I want to store it directly as json in mongo without having to map it to a case class.
{
"_id": {"$oid": "568d23c9af4b609901aad7a2"},
"createdDate" : {"$date" : "2016-01-06T14:25:13.526Z"},
}
When I do:
collection.insert(BSONFormats.BSONDocumentFormat.reads(theJsValue).get)
What I get stored in mongo is:
{
"_id" : ObjectId("568d23c9af4b609901aad7a2"),
"createdDate" : {
"$date" : "2016-01-06T14:25:13.526Z"
}
}
When what I really want is:
{
"_id" : ObjectId("568d23c9af4b609901aad7a2"),
"createdDate" : ISODate("2016-01-06T14:25:13.526Z")
}
}
In other words the only strict-to-shell mode conversion being done is the _id - dates are not being converted. I need the full set of strict mode conversions.
Any ideas ?.