@@ -53,6 +53,36 @@ collection.
5353
5454To learn more about query filters, see the :ref:`kotlin-sync-specify-query` guide.
5555
56+ Find One Document Example
57+ ~~~~~~~~~~~~~~~~~~~~~~~~~
58+
59+ The following example chains the ``first()`` method to the ``find()`` method call to find
60+ the first document in which the value of the ``cuisine`` field is ``"Spanish"``:
61+
62+ .. literalinclude:: /includes/read/retrieve.kt
63+ :start-after: start-find-one
64+ :end-before: end-find-one
65+ :language: kotlin
66+ :copyable:
67+ :dedent:
68+
69+ The ``find()`` operation in the preceding example returns a MongoDB document, which you
70+ can print, as shown in the following example:
71+
72+ .. io-code-block::
73+ :copyable: true
74+
75+ .. input:: /includes/read/retrieve.kt
76+ :start-after: start-find-one-print
77+ :end-before: end-find-one-print
78+ :language: kotlin
79+ :dedent:
80+
81+ .. output::
82+ :visible: false
83+
84+ Restaurant(name=Tropicoso Club, cuisine=Spanish)
85+
5686Find Documents Example
5787~~~~~~~~~~~~~~~~~~~~~~
5888
@@ -124,6 +154,13 @@ modifying queries:
124154 - | Specifies a string to attach to the query. This can help you trace and interpret the
125155 operation in the server logs and in profile data.
126156
157+ * - ``first()``
158+ - | Returns the first document that matches the query or throws a ``MongoClientException``
159+ if no matching documents exist.
160+
161+ * - ``firstOrNull()``
162+ - | Returns the first document that matches the query or ``null`` if no matching documents exist.
163+
127164 * - ``hint()``
128165 - | Specifies the index to use for the query.
129166
0 commit comments