kotlinx.datetime.instant & time series collections

XMLWordPrintableJSON

    • Type: Question
    • Resolution: Works as Designed
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      Summary

      Hello, I am trying to write a data class to a time series collection where the `timeField` has name 'timestamp' and is of type:

      kotlinx.datetime.instant

       

      I have created a codec which simply encodes 

      writer.writeDateTime(value.toEpochMilliseconds())

      however in the logs I see the resulting document:

      "documents": [{"timestamp": "2023-09-18T22:36:28Z", ...}]

      accompanied by the following error message:

      'timestamp' must be present and contain a valid BSON UTC datetime value

      In fact, the only way I can get this to work is if I use kotlinx.serialization and provide a java instant!

      I don't know if there is a driver issue here, but certainly this looks like it should work? If there is a mistake here I think it would be great if the documentation could provide a more comprehensive example!

       

      Driver Version

      4.10.1

            Assignee:
            Ross Lawley
            Reporter:
            Carl Holwell
            None
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: