@@ -159,7 +159,7 @@ contains the additional ``location`` field:
159
159
If multiple documents match the query filter specified in
160
160
the ``ReplaceOneModel`` instance, the operation replaces the first
161
161
result. You can specify a sort in a ``ReplaceOptions`` instance to apply
162
- an order to matched documents before the driver performs the replace
162
+ an order to matched documents before the server performs the replace
163
163
operation, as shown in the following code:
164
164
165
165
.. literalinclude:: /examples/generated/BulkTest.snippet.replace-model-options.kt
@@ -202,7 +202,7 @@ field by ``1`` in a document where the ``_id`` is ``2``:
202
202
If multiple documents match the query filter specified in
203
203
the ``UpdateOneModel`` instance, the operation updates the first
204
204
result. You can specify a sort in an ``UpdateOptions`` instance to apply
205
- an order to matched documents before the driver performs the update
205
+ an order to matched documents before the server performs the update
206
206
operation, as shown in the following code:
207
207
208
208
.. literalinclude:: /examples/generated/BulkTest.snippet.update-model-options.kt
@@ -466,20 +466,65 @@ each write operation applies to.
466
466
.. literalinclude:: /examples/generated/ClientBulkTest.snippet.insert-models.kt
467
467
:language: kotlin
468
468
469
+ .. _kotlin-client-bulk-write-update:
470
+
471
+ Update Operation
472
+ ~~~~~~~~~~~~~~~~
473
+
474
+ The following example shows how to use the ``bulkWrite()`` method to update
475
+ existing documents in the ``db.people`` and ``db.objects`` collections:
476
+
477
+ .. literalinclude:: /examples/generated/ClientBulkTest.snippet.update-models.kt
478
+ :language: kotlin
479
+
480
+ This example increments the value of the ``age`` field by ``1`` in the
481
+ document that has a ``name`` value of ``"Freya Polk"`` in the ``people``
482
+ collection. It also sets the value of the ``manufacturer`` field to
483
+ ``"Premium Technologies"`` in all documents that have a ``category``
484
+ value of ``"electronic"`` in the ``objects`` collection.
485
+
486
+ If multiple documents match the query filter specified in
487
+ a ``ClientNamespacedUpdateOneModel`` instance, the operation updates the
488
+ first result. You can specify a sort order in a `ClientUpdateOneOptions
489
+ <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/bulk/ClientUpdateOneOptions.html>`__
490
+ instance to apply an order to matched documents before the server
491
+ performs the update operation, as shown in the following code:
492
+
493
+ .. code-block:: kotlin
494
+
495
+ val options = ClientUpdateOneOptions
496
+ .clientUpdateOneOptions()
497
+ .sort(Sorts.ascending("_id"))
498
+
499
+ .. _kotlin-client-bulk-write-replace:
500
+
469
501
Replace Operation
470
502
~~~~~~~~~~~~~~~~~
471
503
472
504
The following example shows how to use the ``bulkWrite()`` method to replace
473
- existing documents in the ``sample_db.people`` and ``sample_db.things `` collections.
505
+ existing documents in the ``sample_db.people`` and ``sample_db.objects `` collections.
474
506
475
507
.. literalinclude:: /examples/generated/ClientBulkTest.snippet.replace-models.kt
476
508
:language: kotlin
477
509
478
510
After this example runs successfully, the document that has an ``_id`` value of ``1``
479
511
in the ``people`` collection is replaced with a new document. The document in
480
- the ``things `` collection that has an ``_id`` value of ``1``
512
+ the ``objects `` collection that has an ``_id`` value of ``1``
481
513
is replaced with a new document.
482
514
515
+ If multiple documents match the query filter specified in
516
+ a ``ClientNamespacedReplaceOneModel`` instance, the operation replaces the
517
+ first result. You can specify a sort order in a `ClientReplaceOneOptions
518
+ <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/bulk/ClientReplaceOneOptions.html>`__
519
+ instance to apply an order to matched documents before the driver
520
+ performs the replace operation, as shown in the following code:
521
+
522
+ .. code-block:: kotlin
523
+
524
+ val options = ClientReplaceOneOptions
525
+ .clientReplaceOneOptions()
526
+ .sort(Sorts.ascending("_id"))
527
+
483
528
.. _kotlin-client-bulk-write-options:
484
529
485
530
Bulk Write Options
0 commit comments