@@ -157,10 +157,25 @@ contains an added ``location`` field:
157157 :start-after: begin replaceDocumentsExample
158158 :end-before: end replaceDocumentsExample
159159
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+
160170For more information about the methods and classes mentioned in this section,
161171see the following resources:
162172
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
164179- :manual:`Unique indexes </core/index-unique/>` Server Manual Explanation
165180
166181Update Operation
@@ -193,11 +208,28 @@ the ``age`` field in a document where the ``_id`` is ``2``:
193208 :start-after: begin updateDocumentsExample
194209 :end-before: end updateDocumentsExample
195210
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+
196221For more information about the methods and classes mentioned in this section,
197222see the following resources:
198223
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
201233- :manual:`unique indexes </core/index-unique/>` Server Manual Explanation
202234
203235Delete Operation
0 commit comments