Skip to content

Commit f381e64

Browse files
committed
add bulk info
1 parent d95e0fc commit f381e64

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

source/fundamentals/crud/write-operations/bulk.txt

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
160170
For more information about the methods and classes mentioned in this section,
161171
see 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

166181
Update 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+
196221
For more information about the methods and classes mentioned in this section,
197222
see 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

203235
Delete Operation

source/whats-new.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ and features:
4747

4848
.. replacement:: update-replace-example-link
4949

50-
the :ref:`java-fundamentals-change-document` guide
50+
the :ref:`java-fundamentals-change-document` and :ref:`java-fundamentals-bulkwrite`
51+
guides
5152

5253
- Adds a client bulk write API that allows you to perform write operations on multiple
5354
databases and collections at once. To learn more about this feature, see the

0 commit comments

Comments
 (0)