@@ -159,7 +159,7 @@ contains the additional ``location`` field:
159159If multiple documents match the query filter specified in
160160the ``ReplaceOneModel`` instance, the operation replaces the first
161161result. 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
163163operation, as shown in the following code:
164164
165165.. literalinclude:: /examples/generated/BulkTest.snippet.replace-model-options.kt
@@ -202,7 +202,7 @@ field by ``1`` in a document where the ``_id`` is ``2``:
202202If multiple documents match the query filter specified in
203203the ``UpdateOneModel`` instance, the operation updates the first
204204result. 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
206206operation, as shown in the following code:
207207
208208.. literalinclude:: /examples/generated/BulkTest.snippet.update-model-options.kt
@@ -466,20 +466,65 @@ each write operation applies to.
466466.. literalinclude:: /examples/generated/ClientBulkTest.snippet.insert-models.kt
467467 :language: kotlin
468468
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+
469501Replace Operation
470502~~~~~~~~~~~~~~~~~
471503
472504The 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.
474506
475507.. literalinclude:: /examples/generated/ClientBulkTest.snippet.replace-models.kt
476508 :language: kotlin
477509
478510After this example runs successfully, the document that has an ``_id`` value of ``1``
479511in 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``
481513is replaced with a new document.
482514
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+
483528.. _kotlin-client-bulk-write-options:
484529
485530Bulk Write Options
0 commit comments