@@ -116,7 +116,7 @@ The following example creates an instance of ``UpdateOneModel``:
116
116
If multiple documents match the query filter specified in
117
117
the ``UpdateOneModel`` instance, the operation updates the first
118
118
result. You can specify a sort in an ``UpdateOptions`` instance to apply
119
- an order to matched documents before the driver performs the update
119
+ an order to matched documents before the server performs the update
120
120
operation, as shown in the following code:
121
121
122
122
.. code-block:: java
@@ -156,7 +156,7 @@ The following example creates an instance of ``ReplaceOneModel``:
156
156
If multiple documents match the query filter specified in
157
157
the ``ReplaceOneModel`` instance, the operation replaces the first
158
158
result. You can specify a sort in a ``ReplaceOptions`` instance to apply
159
- an order to matched documents before the driver performs the replace
159
+ an order to matched documents before the server performs the replace
160
160
operation, as shown in the following code:
161
161
162
162
.. code-block:: java
@@ -428,6 +428,43 @@ each write operation applies to.
428
428
:copyable:
429
429
:dedent:
430
430
431
+ .. _java-rs-client-bulk-write-update:
432
+
433
+ Update Operations
434
+ ~~~~~~~~~~~~~~~~~
435
+
436
+ The following example shows how to use the ``bulkWrite()`` method to update
437
+ existing documents in the ``db.people`` and
438
+ ``db.things`` collections:
439
+
440
+ .. literalinclude:: /includes/write/client-bulk-write.java
441
+ :start-after: start-update-models
442
+ :end-before: end-update-models
443
+ :language: java
444
+ :copyable:
445
+ :dedent:
446
+
447
+ This example increments the value of the ``age`` field by ``1`` in the
448
+ document that has a ``name`` value of ``"Freya Polk"`` in the ``people``
449
+ collection. It also sets the value of the ``manufacturer`` field to
450
+ ``"Premium Technologies"`` in all documents that have a ``category``
451
+ value of ``"electronic"`` in the ``things`` collection.
452
+
453
+ If multiple documents match the query filter specified in
454
+ a ``ClientNamespacedUpdateOneModel`` instance, the operation updates the
455
+ first result. You can specify a sort order in a `ClientUpdateOneOptions
456
+ <{+core-api+}/client/model/bulk/ClientUpdateOneOptions.html>`__
457
+ instance to apply an order to matched documents before the server
458
+ performs the update operation, as shown in the following code:
459
+
460
+ .. code-block:: java
461
+
462
+ ClientUpdateOneOptions options = ClientUpdateOneOptions
463
+ .clientUpdateOneOptions()
464
+ .sort(Sorts.ascending("_id"));
465
+
466
+ .. _java-rs-client-bulk-write-replace:
467
+
431
468
Replace Operations
432
469
~~~~~~~~~~~~~~~~~~
433
470
@@ -446,6 +483,19 @@ in the ``people`` collection is replaced with a new document. The document in
446
483
the ``things`` collection that has an ``_id`` value of ``1``
447
484
is replaced with a new document.
448
485
486
+ If multiple documents match the query filter specified in
487
+ a ``ClientNamespacedReplaceOneModel`` instance, the operation replaces the
488
+ first result. You can specify a sort order in a `ClientReplaceOneOptions
489
+ <{+core-api+}/client/model/bulk/ClientReplaceOneOptions.html>`__
490
+ instance to apply an order to matched documents before the server
491
+ performs the replace operation, as shown in the following code:
492
+
493
+ .. code-block:: java
494
+
495
+ ClientReplaceOneOptions options = ClientReplaceOneOptions
496
+ .clientReplaceOneOptions()
497
+ .sort(Sorts.ascending("_id"));
498
+
449
499
Perform the Bulk Operation
450
500
~~~~~~~~~~~~~~~~~~~~~~~~~~
451
501
0 commit comments