@@ -157,10 +157,25 @@ contains an added ``location`` field:
157
157
:start-after: begin replaceDocumentsExample
158
158
:end-before: end replaceDocumentsExample
159
159
160
+ If multiple documents match the query filter specified in
161
+ the ``ReplaceOneModel`` instance, the operation replaces the first
162
+ result. You can specify a sort in a ``ReplaceOptions`` instance to apply
163
+ an order to matched documents before the driver performs the replace
164
+ operation, as shown in the following code:
165
+
166
+ .. code-block:: java
167
+
168
+ ReplaceOptions options = ReplaceOptions.sort(Sorts.ascending("_id"));
169
+
160
170
For more information about the methods and classes mentioned in this section,
161
171
see the following resources:
162
172
163
- - `ReplaceOneModel <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/ReplaceOneModel.html>`__ API documentation
173
+ - `ReplaceOneModel
174
+ <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/ReplaceOneModel.html>`__
175
+ API documentation
176
+ - `ReplaceOptions
177
+ <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/ReplaceOptions.html>`__
178
+ API documentation
164
179
- :manual:`Unique indexes </core/index-unique/>` Server Manual Explanation
165
180
166
181
Update Operation
@@ -193,11 +208,28 @@ the ``age`` field in a document where the ``_id`` is ``2``:
193
208
:start-after: begin updateDocumentsExample
194
209
:end-before: end updateDocumentsExample
195
210
211
+ If multiple documents match the query filter specified in
212
+ the ``UpdateOneModel`` instance, the operation updates the first
213
+ result. You can specify a sort in an ``UpdateOptions`` instance to apply
214
+ an order to matched documents before the driver performs the replace
215
+ operation, as shown in the following code:
216
+
217
+ .. code-block:: java
218
+
219
+ UpdateOptions options = UpdateOptions.sort(Sorts.ascending("_id"));
220
+
196
221
For more information about the methods and classes mentioned in this section,
197
222
see the following resources:
198
223
199
- - `UpdateOneModel <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/UpdateOneModel.html>`__ API documentation
200
- - `UpdateManyModel <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/UpdateManyModel.html>`__ API documentation
224
+ - `UpdateOneModel
225
+ <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/UpdateOneModel.html>`__
226
+ API documentation
227
+ - `UpdateManyModel
228
+ <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/UpdateManyModel.html>`__
229
+ API documentation
230
+ - `UpdateOptions
231
+ <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/UpdateOptions.html>`__
232
+ API documentation
201
233
- :manual:`unique indexes </core/index-unique/>` Server Manual Explanation
202
234
203
235
Delete Operation
0 commit comments