From 2f05bac0c727c6ff371ca461b758f95d6fd66a35 Mon Sep 17 00:00:00 2001 From: norareidy Date: Mon, 9 Sep 2024 13:57:19 -0400 Subject: [PATCH 1/4] DOCSP-41971: Bulk write --- source/write/bulk-write.txt | 313 ++++++++++++++++++++++++++++++++++++ 1 file changed, 313 insertions(+) create mode 100644 source/write/bulk-write.txt diff --git a/source/write/bulk-write.txt b/source/write/bulk-write.txt new file mode 100644 index 00000000..4005531d --- /dev/null +++ b/source/write/bulk-write.txt @@ -0,0 +1,313 @@ +.. _php-bulk-write: + +===================== +Bulk Write Operations +===================== + +.. contents:: On this page + :local: + :backlinks: none + :depth: 2 + :class: singlecol + +.. facet:: + :name: genre + :values: reference + +.. meta:: + :keywords: insert, update, replace, code example + +Overview +-------- + +In this guide, you can learn how to perform multiple write operations +in a single database call by using **bulk write operations**. + +Consider a scenario in which you want to insert a document into a collection, +update multiple other documents, then delete a document. If you use +individual methods, each operation requires its own database call. Instead, +you can use a bulk operation to reduce the number of calls to the database. + +Sample Data +~~~~~~~~~~~ + +The examples in this guide use the ``restaurants`` collection in the ``sample_restaurants`` +database from the :atlas:`Atlas sample datasets `. To access this collection +from your PHP application, instantiate a ``MongoDB\Client`` that connects to an Atlas cluster +and assign the following value to your ``$collection`` variable: + +.. literalinclude:: /includes/write/bulk-write.php + :language: php + :dedent: + :start-after: start-db-coll + :end-before: end-db-coll + +To learn how to create a free MongoDB Atlas cluster and load the sample datasets, see the +:atlas:`Get Started with Atlas ` guide. + +.. _php-bulk-operations: + +Bulk Operations +--------------- + +To run a bulk write operation, pass an array of write operations to the +``MongoDB\Collection::bulkWrite()`` method. You can specify the following +operations in the array: + +.. code-block:: php + + [ + [ 'deleteMany' => [ $filter ] ], + [ 'deleteOne' => [ $filter ] ], + [ 'insertOne' => [ $document ] ], + [ 'replaceOne' => [ $filter, $replacement, $options ] ], + [ 'updateMany' => [ $filter, $update, $options ] ], + [ 'updateOne' => [ $filter, $update, $options ] ], + ] + +.. tip:: + + For more information about delete, insert, replace, and update + operations, see the :ref:`Write operation guides `. + +When you call the ``bulkWrite()`` method, the library automatically runs the +write operations in the order they're specified in the array. To instruct ``bulkWrite()`` +to run the write operations in an arbitrary order, see the :ref:`php-bulk-modify` section. + +Example +~~~~~~~ + +The following example runs a delete, insert, and update operation on the +``restaurants`` collection: + +.. literalinclude:: /includes/write/bulk-write.php + :start-after: start-bulk-insert-one + :end-before: end-bulk-insert-one + :language: php + :dedent: + +To insert multiple documents, create an instance of ``mongocxx::model::insert_one`` +for each document. + +.. _php-bulk-update-model: + +Update Operations +~~~~~~~~~~~~~~~~~ + +To update a document, create an instance of ``mongocxx::model::update_one``. This model +instructs the driver to update *the first* document that matches your query filter. Then, +append the model instance to an instance of the ``mongocxx::bulk_write`` class. + +Pass the following arguments to the ``mongocxx::model::update_one`` model: + +- **Query filter** document, which specifies the criteria used to match documents + in your collection. +- **Update** document, which specifies the kind of update to perform. For more information + about update operations, see the :manual:`Field Update Operators + ` guide in the {+mdb-server+} manual. + +The following example creates an instance of ``mongocxx::model::update_one`` and appends +it to a ``mongocxx::bulk_write`` instance called ``bulk``: + +.. literalinclude:: /includes/write/bulk-write.php + :start-after: start-bulk-update-one + :end-before: end-bulk-update-one + :language: php + :dedent: + +To update multiple documents, create an instance of ``mongocxx::model::update_many`` +and pass in the same arguments. This model instructs the driver to update *all* documents +that match your query filter. + +The following example creates an instance of ``mongocxx::model::update_many`` and appends +it to ``bulk``: + +.. literalinclude:: /includes/write/bulk-write.php + :start-after: start-bulk-update-many + :end-before: end-bulk-update-many + :language: php + :dedent: + +.. _php-bulk-replace-model: + +Replace Operations +~~~~~~~~~~~~~~~~~~ + +A replace operation removes all fields and values of a specified document and +replaces them with new ones. To perform a replace operation, create an instance +of the ``mongocxx::model::replace_one`` class and pass it a query filter and +the fields and values you want to store in the matching document. Then, append +the model instance to an instance of the ``mongocxx::bulk_write`` class. + +The following example creates an instance of ``mongocxx::model::replace_one`` and appends +it to a ``mongocxx::bulk_write`` instance called ``bulk``: + +.. literalinclude:: /includes/write/bulk-write.php + :start-after: start-bulk-replace-one + :end-before: end-bulk-replace-one + :language: php + :dedent: + +To replace multiple documents, you must create a new instance of ``mongocxx::model::replace_one`` +for each document. + +.. _php-bulk-delete-model: + +Delete Operations +~~~~~~~~~~~~~~~~~ + +To delete a document, create an instance of the ``mongocxx::model::delete_one`` class and +pass in a query filter specifying the document you want to delete. This model instructs +the driver to delete only *the first* document that matches your query filter. Then, append +the model instance to an instance of the ``mongocxx::bulk_write`` class. + +The following example creates an instance of ``mongocxx::model::delete_one`` and appends +it to a ``mongocxx::bulk_write`` instance called ``bulk``: + +.. literalinclude:: /includes/write/bulk-write.php + :start-after: start-bulk-delete-one + :end-before: end-bulk-delete-one + :language: php + :dedent: + +To delete multiple documents, create an instance of the ``mongocxx::model::delete_many`` +class and pass in a query filter specifying the document you want to delete. This model +instructs the driver to delete *all* documents that match your query filter. + +The following example creates an instance of ``mongocxx::model::delete_many`` and appends +it to ``bulk``: + +.. literalinclude:: /includes/write/bulk-write.php + :start-after: start-bulk-delete-many + :end-before: end-bulk-delete-many + :language: php + :dedent: + +.. _php-bulk-modify: + +Modify Bulk Write Behavior +-------------------------- + +You can modify the behavior of the ``create_bulk_write()`` method by passing +an instance of the ``mongocxx::options::bulk_write`` class as a parameter. The following +table describes the fields you can set in a ``mongocxx::options::bulk_write`` +instance: + +.. list-table:: + :widths: 30 70 + :header-rows: 1 + + * - Field + - Description + + * - ``ordered`` + - | If ``true``, the driver performs the write operations in the order + provided. If an error occurs, the remaining operations are not + attempted. + | + | If ``false``, the driver performs the operations in an + arbitrary order and attempts to perform all operations. + | Defaults to ``true``. + + * - ``bypass_document_validation`` + - | Specifies whether the operation bypasses document-level validation. For more + information, see :manual:`Schema + Validation ` in the MongoDB + Server manual. + | Defaults to ``false``. + + * - ``write_concern`` + - | Specifies the write concern for the bulk operation. For more information, see + :manual:`Write Concern ` in the {+mdb-server+} manual. + + * - ``comment`` + - | Attaches a comment to the operation. For more information, see the :manual:`delete command + fields ` guide in the + {+mdb-server+} manual. + + * - ``let`` + - | Specifies a document with a list of values to improve operation readability. Values + must be constant or closed expressions that don't reference document fields. For more + information, see the :manual:`let statement + ` in the {+mdb-server+} manual. + +The following example calls the ``create_bulk_write()`` method from the +:ref:`php-bulk-start-operation` example on this page, but sets the ``ordered`` field +of a ``mongocxx::options::bulk_write`` instance to ``false``: + +.. literalinclude:: /includes/write/bulk-write.php + :start-after: start-bulk-write-unordered + :end-before: end-bulk-write-unordered + :language: php + :dedent: + +If any of the write operations in an unordered bulk write fail, the {+driver-short+} +reports the errors only after attempting all operations. + +.. note:: + + Unordered bulk operations do not guarantee order of execution. The order can + differ from the way you list them to optimize the runtime. + +.. _php-bulk-return-value: + +Return Value +------------ + +The ``execute()`` method returns an instance of the ``mongocxx::result::bulk_write`` class. +The ``mongocxx::result::bulk_write`` class contains the following member functions: + +.. list-table:: + :widths: 30 70 + :header-rows: 1 + + * - Function + - Description + + * - ``deleted_count()`` + - | Returns the number of documents deleted, if any. + + * - ``inserted_count()`` + - | Returns the number of documents inserted, if any. + + * - ``matched_count()`` + - | Returns the number of documents matched for an update, if applicable. + + * - ``modified_count()`` + - | Returns the number of documents modified, if any. + + * - ``upserted_count()`` + - | Returns the number of documents upserted, if any. + + * - ``upserted_ids()`` + - | Returns a map of the operation's index to the ``_id`` of the upserted documents, if + applicable. + +Additional Information +---------------------- + +To learn how to perform individual write operations, see the following guides: + +- :ref:`php-write-insert` +- :ref:`php-write-update` +- :ref:`php-write-delete` + +.. TODO: + - :ref:`php-write-replace` + +API Documentation +~~~~~~~~~~~~~~~~~ + +To learn more about any of the methods or types discussed in this +guide, see the following API documentation: + +- `create_bulk_write() <{+api+}/classmongocxx_1_1v__noabi_1_1collection.html#abbf0932175201384cc902c80740adfdc>`__ +- `mongocxx::model::insert_one <{+api+}/classmongocxx_1_1v__noabi_1_1model_1_1insert__one.html>`__ +- `mongocxx::model::update_one <{+api+}/classmongocxx_1_1v__noabi_1_1model_1_1update__one.html>`__ +- `mongocxx::model::update_many <{+api+}/classmongocxx_1_1v__noabi_1_1model_1_1update__many.html>`__ +- `mongocxx::model::replace_one <{+api+}/classmongocxx_1_1v__noabi_1_1model_1_1replace__one.html>`__ +- `mongocxx::model::delete_one <{+api+}/classmongocxx_1_1v__noabi_1_1model_1_1delete__one.html>`__ +- `mongocxx::model::delete_many <{+api+}/classmongocxx_1_1v__noabi_1_1model_1_1delete__many.html>`__ +- `execute() <{+api+}/classmongocxx_1_1v__noabi_1_1bulk__write.html#a13476d87ed6d00dca52c39dc04b98568>`__ +- `mongocxx::options::bulk_write <{+api+}/classmongocxx_1_1v__noabi_1_1options_1_1bulk__write.html>`__ +- `mongocxx::result::bulk_write <{+api+}/classmongocxx_1_1v__noabi_1_1result_1_1bulk__write.html>`__ From d0a12bddf0a2a6cd076bba2586b020f61aee9a9b Mon Sep 17 00:00:00 2001 From: norareidy Date: Mon, 9 Sep 2024 17:55:14 -0400 Subject: [PATCH 2/4] edits --- source/includes/write/bulk-write.php | 57 +++++++ source/tutorial/codecs.txt | 2 + source/write.txt | 3 +- source/write/bulk-write.txt | 232 +++++++++------------------ 4 files changed, 135 insertions(+), 159 deletions(-) create mode 100644 source/includes/write/bulk-write.php diff --git a/source/includes/write/bulk-write.php b/source/includes/write/bulk-write.php new file mode 100644 index 00000000..a3543a22 --- /dev/null +++ b/source/includes/write/bulk-write.php @@ -0,0 +1,57 @@ +sample_restaurants->restaurants; +// end-db-coll + +// start-run-bulk +$result = $collection->bulkWrite( + [ + [ + 'insertOne' => [ + ['name' => 'Mongo\'s Deli'], + ['cuisine' => 'Sandwiches'], + ['borough' => 'Manhattan'], + ['restaurant_id' => '1234'], + ], + ], + [ + 'updateOne' => [ + ['name' => 'Mongo\'s Deli'], + ['$set' => ['cuisine' => 'Sandwiches and Salads']], + ], + ], + [ + 'deleteMany' => [ + ['borough' => 'Manhattan'], + ], + ], + ] +); +// end-run-bulk + +// start-bulk-options +$result = $collection->bulkWrite( + [ + [ + 'insertOne' => [ + ['name' => 'Mongo\'s Pizza'], + ['cuisine' => 'Italian'], + ['borough' => 'Queens'], + ['restaurant_id' => '5678'], + ], + ], + [ + 'deleteOne' => [ + ['restaurant_id' => '5678'], + ], + ], + ], + ['ordered' => false] +); +// end-bulk-options diff --git a/source/tutorial/codecs.txt b/source/tutorial/codecs.txt index a4bb5dd6..44a6f41f 100644 --- a/source/tutorial/codecs.txt +++ b/source/tutorial/codecs.txt @@ -1,3 +1,5 @@ +.. _php-codecs: + ====== Codecs ====== diff --git a/source/write.txt b/source/write.txt index 9053d5a4..25b60312 100644 --- a/source/write.txt +++ b/source/write.txt @@ -8,4 +8,5 @@ Write Data to MongoDB :titlesonly: :maxdepth: 1 - /write/update \ No newline at end of file + /write/update + /write/bulk-write \ No newline at end of file diff --git a/source/write/bulk-write.txt b/source/write/bulk-write.txt index 4005531d..85550d5d 100644 --- a/source/write/bulk-write.txt +++ b/source/write/bulk-write.txt @@ -51,8 +51,8 @@ Bulk Operations --------------- To run a bulk write operation, pass an array of write operations to the -``MongoDB\Collection::bulkWrite()`` method. You can specify the following -operations in the array: +``MongoDB\Collection::bulkWrite()`` method. Use the following syntax to +specify the write operations: .. code-block:: php @@ -77,109 +77,21 @@ to run the write operations in an arbitrary order, see the :ref:`php-bulk-modify Example ~~~~~~~ -The following example runs a delete, insert, and update operation on the -``restaurants`` collection: +This example runs the following write operations on the ``restaurants`` +collection: -.. literalinclude:: /includes/write/bulk-write.php - :start-after: start-bulk-insert-one - :end-before: end-bulk-insert-one - :language: php - :dedent: - -To insert multiple documents, create an instance of ``mongocxx::model::insert_one`` -for each document. - -.. _php-bulk-update-model: - -Update Operations -~~~~~~~~~~~~~~~~~ +- Insert operation, which inserts a document in which the ``name`` value is + ``'Mongo's Deli'`` -To update a document, create an instance of ``mongocxx::model::update_one``. This model -instructs the driver to update *the first* document that matches your query filter. Then, -append the model instance to an instance of the ``mongocxx::bulk_write`` class. +- Update operation, which updates the ``cuisine`` field of a document in + which the ``name`` value is ``'Mongo's Deli'`` -Pass the following arguments to the ``mongocxx::model::update_one`` model: - -- **Query filter** document, which specifies the criteria used to match documents - in your collection. -- **Update** document, which specifies the kind of update to perform. For more information - about update operations, see the :manual:`Field Update Operators - ` guide in the {+mdb-server+} manual. - -The following example creates an instance of ``mongocxx::model::update_one`` and appends -it to a ``mongocxx::bulk_write`` instance called ``bulk``: +- Delete operation, which deletes all documents in which the ``borough`` value + is ``'Manhattan'`` .. literalinclude:: /includes/write/bulk-write.php - :start-after: start-bulk-update-one - :end-before: end-bulk-update-one - :language: php - :dedent: - -To update multiple documents, create an instance of ``mongocxx::model::update_many`` -and pass in the same arguments. This model instructs the driver to update *all* documents -that match your query filter. - -The following example creates an instance of ``mongocxx::model::update_many`` and appends -it to ``bulk``: - -.. literalinclude:: /includes/write/bulk-write.php - :start-after: start-bulk-update-many - :end-before: end-bulk-update-many - :language: php - :dedent: - -.. _php-bulk-replace-model: - -Replace Operations -~~~~~~~~~~~~~~~~~~ - -A replace operation removes all fields and values of a specified document and -replaces them with new ones. To perform a replace operation, create an instance -of the ``mongocxx::model::replace_one`` class and pass it a query filter and -the fields and values you want to store in the matching document. Then, append -the model instance to an instance of the ``mongocxx::bulk_write`` class. - -The following example creates an instance of ``mongocxx::model::replace_one`` and appends -it to a ``mongocxx::bulk_write`` instance called ``bulk``: - -.. literalinclude:: /includes/write/bulk-write.php - :start-after: start-bulk-replace-one - :end-before: end-bulk-replace-one - :language: php - :dedent: - -To replace multiple documents, you must create a new instance of ``mongocxx::model::replace_one`` -for each document. - -.. _php-bulk-delete-model: - -Delete Operations -~~~~~~~~~~~~~~~~~ - -To delete a document, create an instance of the ``mongocxx::model::delete_one`` class and -pass in a query filter specifying the document you want to delete. This model instructs -the driver to delete only *the first* document that matches your query filter. Then, append -the model instance to an instance of the ``mongocxx::bulk_write`` class. - -The following example creates an instance of ``mongocxx::model::delete_one`` and appends -it to a ``mongocxx::bulk_write`` instance called ``bulk``: - -.. literalinclude:: /includes/write/bulk-write.php - :start-after: start-bulk-delete-one - :end-before: end-bulk-delete-one - :language: php - :dedent: - -To delete multiple documents, create an instance of the ``mongocxx::model::delete_many`` -class and pass in a query filter specifying the document you want to delete. This model -instructs the driver to delete *all* documents that match your query filter. - -The following example creates an instance of ``mongocxx::model::delete_many`` and appends -it to ``bulk``: - -.. literalinclude:: /includes/write/bulk-write.php - :start-after: start-bulk-delete-many - :end-before: end-bulk-delete-many + :start-after: start-run-bulk + :end-before: end-run-bulk :language: php :dedent: @@ -188,61 +100,69 @@ it to ``bulk``: Modify Bulk Write Behavior -------------------------- -You can modify the behavior of the ``create_bulk_write()`` method by passing -an instance of the ``mongocxx::options::bulk_write`` class as a parameter. The following -table describes the fields you can set in a ``mongocxx::options::bulk_write`` -instance: +You can modify the behavior of the ``MongoDB\Collection::bulkWrite()`` method by +passing an array that specifies option values as a parameter. The following table +describes the options you can set in the array: .. list-table:: :widths: 30 70 :header-rows: 1 - * - Field + * - Option - Description - * - ``ordered`` - - | If ``true``, the driver performs the write operations in the order - provided. If an error occurs, the remaining operations are not - attempted. - | - | If ``false``, the driver performs the operations in an - arbitrary order and attempts to perform all operations. - | Defaults to ``true``. - - * - ``bypass_document_validation`` - - | Specifies whether the operation bypasses document-level validation. For more - information, see :manual:`Schema + * - ``bypassDocumentValidation`` + - | Specifies whether the operation bypasses document validation. This lets you + modify documents that don't meet the schema validation requirements, if any + exist. For more information about schema validation, see :manual:`Schema Validation ` in the MongoDB Server manual. | Defaults to ``false``. - * - ``write_concern`` - - | Specifies the write concern for the bulk operation. For more information, see - :manual:`Write Concern ` in the {+mdb-server+} manual. + * - ``codec`` + - | Sets the codec to use for encoding or decoding documents. Bulk writes + use the codec for ``insertOne()`` and ``replaceOne()`` operations. + For more information, see the :ref:`php-codecs` guide. + + * - ``writeConcern`` + - | Sets the write concern for the operation. + For more information, see :manual:`Write Concern ` + in the {+mdb-server+} manual. + + * - ``let`` + - | Specifies a document with a list of values to improve operation readability. + Values must be constant or closed expressions that don't reference document + fields. For more information, see the :manual:`let statement + ` in the + {+mdb-server+} manual. + + * - ``ordered`` + - | If set to ``true``: when a single write fails, the operation stops without + performing the remaining writes and throws an exception. + | If set to ``false``: when a single write fails, the operation continues to + attempt the remaining write operations, if any, and throws an exception. + | Defaults to ``true``. * - ``comment`` - - | Attaches a comment to the operation. For more information, see the :manual:`delete command - fields ` guide in the + - | Attaches a comment to the operation. For more information, see the :manual:`insert command + fields ` guide in the {+mdb-server+} manual. - * - ``let`` - - | Specifies a document with a list of values to improve operation readability. Values - must be constant or closed expressions that don't reference document fields. For more - information, see the :manual:`let statement - ` in the {+mdb-server+} manual. + * - ``session`` + - | Specifies the client session to associate with the operation. -The following example calls the ``create_bulk_write()`` method from the -:ref:`php-bulk-start-operation` example on this page, but sets the ``ordered`` field -of a ``mongocxx::options::bulk_write`` instance to ``false``: +The following example calls the ``bulkWrite()`` method to perform an +insert and delete operation and sets the ``ordered`` option to +``false``: .. literalinclude:: /includes/write/bulk-write.php - :start-after: start-bulk-write-unordered - :end-before: end-bulk-write-unordered + :start-after: start-bulk-options + :end-before: end-bulk-options :language: php :dedent: -If any of the write operations in an unordered bulk write fail, the {+driver-short+} -reports the errors only after attempting all operations. +If the library runs the insert operation first, one document is deleted. +If it runs the delete operation first, no documents are deleted. .. note:: @@ -254,8 +174,8 @@ reports the errors only after attempting all operations. Return Value ------------ -The ``execute()`` method returns an instance of the ``mongocxx::result::bulk_write`` class. -The ``mongocxx::result::bulk_write`` class contains the following member functions: +The ``MongoDB\Collection::bulkWrite()`` method returns a ``MongoDB\BulkWriteResult`` +object. This class contains the following member functions: .. list-table:: :widths: 30 70 @@ -264,24 +184,30 @@ The ``mongocxx::result::bulk_write`` class contains the following member functio * - Function - Description - * - ``deleted_count()`` + * - ``getDeletedCount()`` - | Returns the number of documents deleted, if any. - * - ``inserted_count()`` + * - ``getInsertedCount()`` - | Returns the number of documents inserted, if any. - * - ``matched_count()`` - - | Returns the number of documents matched for an update, if applicable. + * - ``getInsertedIds()`` + - | Returns a map of ``_id`` field values for inserted documents, if any. - * - ``modified_count()`` + * - ``getMatchedCount()`` + - | Returns the number of documents matched during update and replace + operations, if applicable. + + * - ``getModifiedCount()`` - | Returns the number of documents modified, if any. - * - ``upserted_count()`` + * - ``getUpsertedCount()`` - | Returns the number of documents upserted, if any. - * - ``upserted_ids()`` - - | Returns a map of the operation's index to the ``_id`` of the upserted documents, if - applicable. + * - ``getUpsertedIds()`` + - | Returns a map of ``_id`` field values for upserted documents, if any. + + * - ``isAcknowledged()`` + - | Returns a boolean indicating whether the bulk operation was acknowledged. Additional Information ---------------------- @@ -291,9 +217,7 @@ To learn how to perform individual write operations, see the following guides: - :ref:`php-write-insert` - :ref:`php-write-update` - :ref:`php-write-delete` - -.. TODO: - - :ref:`php-write-replace` +- :ref:`php-write-replace` API Documentation ~~~~~~~~~~~~~~~~~ @@ -301,13 +225,5 @@ API Documentation To learn more about any of the methods or types discussed in this guide, see the following API documentation: -- `create_bulk_write() <{+api+}/classmongocxx_1_1v__noabi_1_1collection.html#abbf0932175201384cc902c80740adfdc>`__ -- `mongocxx::model::insert_one <{+api+}/classmongocxx_1_1v__noabi_1_1model_1_1insert__one.html>`__ -- `mongocxx::model::update_one <{+api+}/classmongocxx_1_1v__noabi_1_1model_1_1update__one.html>`__ -- `mongocxx::model::update_many <{+api+}/classmongocxx_1_1v__noabi_1_1model_1_1update__many.html>`__ -- `mongocxx::model::replace_one <{+api+}/classmongocxx_1_1v__noabi_1_1model_1_1replace__one.html>`__ -- `mongocxx::model::delete_one <{+api+}/classmongocxx_1_1v__noabi_1_1model_1_1delete__one.html>`__ -- `mongocxx::model::delete_many <{+api+}/classmongocxx_1_1v__noabi_1_1model_1_1delete__many.html>`__ -- `execute() <{+api+}/classmongocxx_1_1v__noabi_1_1bulk__write.html#a13476d87ed6d00dca52c39dc04b98568>`__ -- `mongocxx::options::bulk_write <{+api+}/classmongocxx_1_1v__noabi_1_1options_1_1bulk__write.html>`__ -- `mongocxx::result::bulk_write <{+api+}/classmongocxx_1_1v__noabi_1_1result_1_1bulk__write.html>`__ +- `MongoDB\\Collection::bulkWrite() <{+api+}/method/MongoDBCollection-bulkWrite>`__ +- `MongoDB\\BulkWriteResult <{+api+}/class/MongoDBBulkWriteResult>`__ \ No newline at end of file From f793c805635feb919f56512cc06475e5d9bba821 Mon Sep 17 00:00:00 2001 From: norareidy Date: Tue, 10 Sep 2024 11:28:54 -0400 Subject: [PATCH 3/4] JS feedback --- source/write/bulk-write.txt | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/source/write/bulk-write.txt b/source/write/bulk-write.txt index 85550d5d..33c0d274 100644 --- a/source/write/bulk-write.txt +++ b/source/write/bulk-write.txt @@ -71,8 +71,9 @@ specify the write operations: operations, see the :ref:`Write operation guides `. When you call the ``bulkWrite()`` method, the library automatically runs the -write operations in the order they're specified in the array. To instruct ``bulkWrite()`` -to run the write operations in an arbitrary order, see the :ref:`php-bulk-modify` section. +write operations in the order they're specified in the array. To learn how to +instruct ``bulkWrite()`` to run the write operations in an arbitrary order, +see the :ref:`php-bulk-modify` section. Example ~~~~~~~ @@ -80,13 +81,13 @@ Example This example runs the following write operations on the ``restaurants`` collection: -- Insert operation, which inserts a document in which the ``name`` value is +- **Insert operation** to insert a document in which the ``name`` value is ``'Mongo's Deli'`` -- Update operation, which updates the ``cuisine`` field of a document in +- **Update operation** to update the ``cuisine`` field of a document in which the ``name`` value is ``'Mongo's Deli'`` -- Delete operation, which deletes all documents in which the ``borough`` value +- **Delete operation** to delete all documents in which the ``borough`` value is ``'Manhattan'`` .. literalinclude:: /includes/write/bulk-write.php @@ -115,8 +116,8 @@ describes the options you can set in the array: - | Specifies whether the operation bypasses document validation. This lets you modify documents that don't meet the schema validation requirements, if any exist. For more information about schema validation, see :manual:`Schema - Validation ` in the MongoDB - Server manual. + Validation ` in the {+mdb-server+} + manual. | Defaults to ``false``. * - ``codec`` @@ -140,7 +141,7 @@ describes the options you can set in the array: - | If set to ``true``: when a single write fails, the operation stops without performing the remaining writes and throws an exception. | If set to ``false``: when a single write fails, the operation continues to - attempt the remaining write operations, if any, and throws an exception. + attempt the remaining write operations, if any, then throws an exception. | Defaults to ``true``. * - ``comment`` From 996e74bfde1f9ae3b488cc1e70b337e5d15ee7c4 Mon Sep 17 00:00:00 2001 From: norareidy Date: Tue, 17 Sep 2024 10:51:06 -0400 Subject: [PATCH 4/4] api links --- source/write/bulk-write.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/write/bulk-write.txt b/source/write/bulk-write.txt index 33c0d274..bf9abcec 100644 --- a/source/write/bulk-write.txt +++ b/source/write/bulk-write.txt @@ -226,5 +226,5 @@ API Documentation To learn more about any of the methods or types discussed in this guide, see the following API documentation: -- `MongoDB\\Collection::bulkWrite() <{+api+}/method/MongoDBCollection-bulkWrite>`__ -- `MongoDB\\BulkWriteResult <{+api+}/class/MongoDBBulkWriteResult>`__ \ No newline at end of file +- :phpmethod:`MongoDB\Collection::bulkWrite()` +- :phpclass:`MongoDB\BulkWriteResult` \ No newline at end of file