Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-5167

kotlinx.datetime.instant & time series collections

    XMLWordPrintableJSON

Details

    • Icon: Question Question
    • Resolution: Works as Designed
    • Icon: Unknown Unknown
    • None
    • 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?

    Description

      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

      Attachments

        Activity

          People

            ross@mongodb.com Ross Lawley
            dev@noisysoftware.com Carl Holwell
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: