I'm having a bit of trouble with timestamps in mongocxx. (I know that object creation time is encoded in the oid.)
I have an object that looks like this in the mongo shell:
...
"server_time" : ISODate("2016-11-17T21:47:07.141Z"),
...
and in C++ when I say
LOG_INFO << bsoncxx::to_json(doc);
I see this (newlines added here for readability):
{ "_id" : { "$oid" : "..." },
...,
"server_time" : { "$date" : 1479419227141 }
}
So I try
doc["server_time"].get_timestamp().timestamp
and get an exception, "expected element type k_timestamp". So maybe it just looks like a timestamp but isn't. No worries, I'll try this:
doc["server_time"]["$date"].get_int64().value / 1000
and now I throw with message "unset document::element".
Can anyone point me to what mongocxx is hoping for here?
Thanks.