@@ -55,7 +55,7 @@ Atlas </getting-started>` guide.
5555The documents in these collections are modeled by the following
5656{+language+} data classes:
5757
58- .. literalinclude:: /includes/write/bulk.kt
58+ .. literalinclude:: /includes/write/client- bulk-write .kt
5959 :start-after: start-data-classes
6060 :end-before: end-data-classes
6161 :language: kotlin
@@ -138,7 +138,7 @@ The following example creates an instance of ``UpdateOneModel``:
138138If multiple documents match the query filter specified in
139139the ``UpdateOneModel`` instance, the operation updates the first
140140result. You can specify a sort in an ``UpdateOptions`` instance to apply
141- an order to matched documents before the driver performs the update
141+ an order to matched documents before the server performs the update
142142operation, as shown in the following code:
143143
144144.. code-block:: kotlin
@@ -181,7 +181,7 @@ The following example creates an instance of ``ReplaceOneModel``:
181181If multiple documents match the query filter specified in
182182the ``ReplaceOneModel`` instance, the operation replaces the first
183183result. You can specify a sort in a ``ReplaceOptions`` instance to apply
184- an order to matched documents before the driver performs the replace
184+ an order to matched documents before the server performs the replace
185185operation, as shown in the following code:
186186
187187.. code-block:: kotlin
@@ -467,8 +467,8 @@ Insert Operations
467467~~~~~~~~~~~~~~~~~
468468
469469This example shows how to create models that contain instructions to
470- insert two documents. One document is inserted into the ``db.people ``
471- collection, and the other document is inserted into the ``db.things `` collection.
470+ insert two documents. One document is inserted into the ``sample_restaurants.restaurants ``
471+ collection, and the other document is inserted into the ``sample_mflix.movies `` collection.
472472The ``MongoNamespace`` instance defines the target database and collection that
473473each write operation applies to.
474474
@@ -479,11 +479,49 @@ each write operation applies to.
479479 :copyable:
480480 :dedent:
481481
482+ .. _kotlin-sync-client-bulk-write-update:
483+
484+ Update Operation
485+ ~~~~~~~~~~~~~~~~
486+
487+ The following example shows how to use the ``bulkWrite()`` method to update
488+ existing documents in the ``sample_restaurants.restaurants`` and
489+ ``sample_mflix.movies`` collections:
490+
491+ .. literalinclude:: /includes/write/client-bulk-write.kt
492+ :start-after: start-update-models
493+ :end-before: end-update-models
494+ :language: kotlin
495+ :copyable:
496+ :dedent:
497+
498+ This example increments the value of the ``stars`` field by ``1`` in the
499+ document that has a ``name`` value of ``"Villa Berulia"`` in the
500+ ``restaurants`` collection. It also sets the value of the ``seen`` field
501+ to ``true`` in all documents that have a ``title`` value of ``"Carrie"``
502+ in the ``movies`` collection.
503+
504+ If multiple documents match the query filter specified in
505+ a ``ClientNamespacedUpdateOneModel`` instance, the operation updates the
506+ first result. You can specify a sort order in a `ClientUpdateOneOptions
507+ <{+core-api+}/com/mongodb/client/model/bulk/ClientUpdateOneOptions.html>`__
508+ instance to apply an order to matched documents before the server
509+ performs the update operation, as shown in the following code:
510+
511+ .. code-block:: kotlin
512+
513+ val options = ClientUpdateOneOptions
514+ .clientUpdateOneOptions()
515+ .sort(Sorts.ascending("_id"))
516+
517+ .. _kotlin-sync-client-bulk-write-replace:
518+
482519Replace Operations
483520~~~~~~~~~~~~~~~~~~
484521
485522The following example shows how to create models to replace
486- existing documents in the ``db.people`` and ``db.things`` collections:
523+ existing documents in the ``sample_restaurants.restaurants`` and
524+ ``sample_mflix.movies`` collections:
487525
488526.. literalinclude:: /includes/write/client-bulk-write.kt
489527 :start-after: start-replace-models
@@ -493,9 +531,22 @@ existing documents in the ``db.people`` and ``db.things`` collections:
493531 :dedent:
494532
495533After this example runs successfully, the document that has an ``_id`` value of ``1``
496- in the ``people`` collection is replaced with a new document. The document in
497- the ``things`` collection that has an ``_id`` value of ``1``
498- is replaced with a new document.
534+ in the ``restaurants`` collection is replaced with a new document. The document in
535+ the ``movies`` collection that has an ``_id`` value of ``1``
536+ is also replaced with a new document.
537+
538+ If multiple documents match the query filter specified in
539+ a ``ClientNamespacedReplaceOneModel`` instance, the operation replaces the
540+ first result. You can specify a sort order in a `ClientReplaceOneOptions
541+ <{+core-api+}/com/mongodb/client/model/bulk/ClientReplaceOneOptions.html>`__
542+ instance to apply an order to matched documents before the driver
543+ performs the replace operation, as shown in the following code:
544+
545+ .. code-block:: kotlin
546+
547+ val options = ClientReplaceOneOptions
548+ .clientReplaceOneOptions()
549+ .sort(Sorts.ascending("_id"))
499550
500551Perform the Bulk Operation
501552~~~~~~~~~~~~~~~~~~~~~~~~~~
0 commit comments