Skip to content

Commit 2e0bb0c

Browse files
authored
Docsp 25493 record codec topic (#327)
* DOCSP-25493: Added section about using the RecordCodexProvider * Fix broken link. * Updated based on PR feedback. * Feedback updates. * Minor typo clean up
1 parent 8a7413b commit 2e0bb0c

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

source/fundamentals/data-formats/document-data-format-record.txt

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ You can use the following annotations on record components:
131131
- Specifies a BSON type to store when different from the record component
132132
type. Accepts the BSON type as the parameter.
133133

134+
.. note::
135+
136+
The driver supports annotations for Java records, but only if you include them
137+
when you define the component as shown in the following example record. You
138+
cannot use the annotations inside the record constructor.
139+
134140
Example Annotated Record
135141
~~~~~~~~~~~~~~~~~~~~~~~~
136142

@@ -225,4 +231,20 @@ execute a find operation on a collection of ``RecordTree`` types:
225231
.. output::
226232
:language: sh
227233

228-
RecordTree[content=Ranginui, left=RecordTree[content=..., left=RecordTree[content=..., right=RecordTree[content=Ikatere...]]
234+
RecordTree[content=Ranginui, left=RecordTree[content=..., left=RecordTree[content=..., right=RecordTree[content=Ikatere...]]
235+
236+
.. _fundamentals-records-get-codec:
237+
238+
Retrieve the Record Codec
239+
-------------------------
240+
241+
You can use the ``RecordCodecProvider`` to retrieve the
242+
record codec. You should use this interface when you want to customize the codec to encode
243+
and decode Java record objects to and from corresponding BSON types while
244+
minimizing duplicate code. To learn more about codecs and their usage,
245+
see :ref:`Codecs <fundamentals-codecs>`.
246+
247+
You can't create a record codec directly, but you can use the
248+
``RecordCodecProvider`` to implement the record codec in your code. Learn more
249+
about the ``RecordCodecProvider``, see the
250+
`API documentation <{+api+}/apidocs/bson-record-codec/org/bson/codecs/record/RecordCodecProvider.html>`__.

0 commit comments

Comments
 (0)