-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DOCSP-41865: datetime serializers #173
DOCSP-41865: datetime serializers #173
Conversation
✅ Deploy Preview for docs-kotlin ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice job. a few thoughts and questions
``kotlinx-datetime`` is a {+language+} library that allows | ||
you to work with dates and times. If you want a high level of control | ||
over how your date and time values are serialized, you can add the | ||
dependency to your project's dependency list. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: maybe a little more straightforward
``kotlinx-datetime`` is a {+language+} library that allows | |
you to work with dates and times. If you want a high level of control | |
over how your date and time values are serialized, you can add the | |
dependency to your project's dependency list. | |
``kotlinx-datetime`` is a {+language+} library that offers | |
a high level of control over how your date and time values | |
are serialized. To use the library, add the ``kotlinx-datetime`` | |
dependency to your project's dependency list. |
source/whats-new.txt
Outdated
|
||
.. sharedinclude:: dbx/jvm/v5.2-wn-items.rst | ||
|
||
.. replacement:: avs-index-link | ||
|
||
:ref:`kotlin-search-indexes` in the Indexes guide | ||
|
||
- Adds support for serializers from the ``kotlinx-datetime`` library | ||
that let you map to BSON as the expected types instead of as strings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: specify type(s)
that let you map to BSON as the expected types instead of as strings. | |
that let you map ``LocalDate``[?] values to BSON as the expected types instead of as strings. |
source/whats-new.txt
Outdated
- Adds support for serializers from the ``kotlinx-datetime`` library | ||
that let you map to BSON as the expected types instead of as strings. | ||
To learn more, see the :ref:`kotlin-datetime-serialization` section of | ||
the Kotlin Serialization guide. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could use source constant here
the Kotlin Serialization guide. | |
the {+language+} Serialization guide. |
The following ``Appointment`` data class has the ``@Serializable`` | ||
annotation and the ``@Contextual`` annotation on the ``date`` field | ||
to use the ``kotlinx-datetime`` serializer for ``LocalDate`` values. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: i had a little trouble parsing this all at first. i tried a few versions and ended up with a list, but feel free to use/discard parts as you see fit. it also sort of bleeds into the following example about the time being stored as a string.
The following ``Appointment`` data class has the ``@Serializable`` | |
annotation and the ``@Contextual`` annotation on the ``date`` field | |
to use the ``kotlinx-datetime`` serializer for ``LocalDate`` values. | |
In the following code example, the driver serializes all fields in | |
the ``Appointment`` data class in the following ways: | |
- ``name``: The driver serializes the value as a string. | |
- ``date``: The driver uses the ``kotlinx-datetime`` serializer because | |
the field includes the ``@Contextual`` annotation. The value is serialized | |
as a BSON date. | |
- ``time``: The driver serializes the value as a string. |
The following ``Appointment`` data class has the ``@Serializable`` | ||
annotation and the ``@Contextual`` annotation on the ``date`` field | ||
to use the ``kotlinx-datetime`` serializer for ``LocalDate`` values. | ||
Values of the ``time`` field are stored as strings, because the driver |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: Does this code example show that the time
field is stored as a string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, this is the default behavior of the driver. The result is shown later in the section
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM w/ 1 suggestion
because the field has the ``@Contextual`` annotation. So, | ||
``LocalDate`` values are serialized as BSON dates. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S:
because the field has the ``@Contextual`` annotation. So, | |
``LocalDate`` values are serialized as BSON dates. | |
because the field has the ``@Contextual`` annotation. | |
``LocalDate`` values are serialized as BSON dates. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Pull Request Info
PR Reviewing Guidelines
JIRA - https://jira.mongodb.org/browse/DOCSP-41865
Staging:
note that the test is failing because of #170
Self-Review Checklist