@@ -116,6 +116,16 @@ The following example creates an instance of ``UpdateOneModel``:
116
116
:copyable:
117
117
:dedent:
118
118
119
+ If multiple documents match the query filter specified in
120
+ the ``UpdateOneModel`` instance, the operation updates the first
121
+ result. You can specify a sort in an ``UpdateOptions`` instance to apply
122
+ an order to matched documents before the driver performs the update
123
+ operation, as shown in the following code:
124
+
125
+ .. code-block:: java
126
+
127
+ val opts = UpdateOptions().sort(Sorts.ascending(Restaurant::name.name))
128
+
119
129
To update multiple documents, create an instance of ``UpdateManyModel`` and pass
120
130
the same arguments as for ``UpdateOneModel``. The ``UpdateManyModel``
121
131
class specifies updates for *all* documents that match your query
@@ -148,8 +158,20 @@ The following example creates an instance of ``ReplaceOneModel``:
148
158
:copyable:
149
159
:dedent:
150
160
151
- To replace multiple documents, you must create an instance of
152
- ``ReplaceOneModel`` for each document.
161
+ If multiple documents match the query filter specified in
162
+ the ``ReplaceOneModel`` instance, the operation replaces the first
163
+ result. You can specify a sort in a ``ReplaceOptions`` instance to apply
164
+ an order to matched documents before the driver performs the replace
165
+ operation, as shown in the following code:
166
+
167
+ .. code-block:: java
168
+
169
+ val opts = ReplaceOptions().sort(Sorts.ascending(Restaurant::name.name))
170
+
171
+ .. tip:: Replace Multiple Documents
172
+
173
+ To replace multiple documents, create an instance of
174
+ ``ReplaceOneModel`` for each document.
153
175
154
176
Delete Operations
155
177
~~~~~~~~~~~~~~~~~
0 commit comments