/action/insertOne in the MongoDB API works like a charm for standard data, but we are struggling to do the same for a time series database. Without fail, we are getting
‘t’ must be present and contain a valid BSON UTC datetime value
no matter how we are trying to format the timestamp.
The only API doc reference made to timestamps we find is:
{ "T": 1565545664, "I": 1}
None of the other timestamp formats used with MongoDB, seem to apply to JSON payloads.
Would be grateful for any pointers into how to approach this!
Thanks!
CodePudding user response:
{ "T": 1565545664, "I": 1}
looks like a Timestamp value, not a UTC datetime.
According to the BSON spec those are different types.
Since the UTC datetime type contains the number of milliseconds since 1 Jan 1970, you might try one of these:
{"t": 1565545664000}
{"t": {"$date": 1565545664000}}