-
Notifications
You must be signed in to change notification settings - Fork 52
DOCSP-44681: Client bulk write #984
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DOCSP-44681: Client bulk write #984
Conversation
✅ Deploy Preview for docs-node ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few fixes:
- Specifies two ``InsertOneModel`` instances in an array. Each ``InsertOneModel`` | ||
represents a document to insert into the ``movies`` collection in the | ||
``sample_mflix`` database. | ||
- Calls the ``bulkWrite()`` method on the ``movies`` collection and passes an | ||
array of models as a parameter. | ||
- Prints the number of inserted documents. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be an ordered list - same for the the other lists describing steps in an example.
:language: javascript | ||
:dedent: | ||
|
||
.. output:: | ||
:language: console | ||
:visible: false | ||
|
||
Inserted documents: 4 | ||
Inserted documents: 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be 3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops
databases, create a ``ClientBulkWriteModel`` for each operation. Then, | ||
call the ``bulkWrite()`` method on your client and pass an array of | ||
models as a parameter. Use the following syntax to create | ||
a ``ClientBulkWriteModel`` that specifies an insert operation: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c+p error?
a ``ClientBulkWriteModel`` that specifies an insert operation: | |
a ``ClientBulkWriteModel`` that specifies a replace operation: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, thanks for catching!
.. code-block:: javascript | ||
:copyable: false | ||
|
||
{ | ||
namespace: "<db>.<collection>", | ||
name: "insertOne", | ||
document: <document to insert> | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Through out this doc you're using a table to describe fields for the collection operations and a code block for the client operations. I think you should use a table for all descriptions. Most of the descriptions will be duplicated from the collection sections, but I think we should assume people will be reading sections individually, and so should provide that same level of detail in each. It also clarifies that the descriptions actually do apply, rather than relying on that assumption.
Also, there's some weird highlighting happening with the blocks because you're using pseudocode.
The ``BulkWriteResult`` object has the following fields: | ||
|
||
- ``insertedCount``: the number of inserted documents | ||
- ``matchedCount``: the number of matched documents | ||
- ``modifiedCount``: the number of updated documents | ||
- ``upsertedCount``: the number of upserted documents | ||
- ``deletedCount``: the number of deleted documents | ||
- ``insertedCount``: The number of inserted documents | ||
- ``matchedCount``: The number of matched documents | ||
- ``modifiedCount``: The number of updated documents | ||
- ``upsertedCount``: The number of upserted documents | ||
- ``deletedCount``: The number of deleted documents | ||
|
||
The ``MongoClient.bulkWrite()`` method returns a ``ClientBulkWriteResult`` object, | ||
which has the following fields: | ||
|
||
- ``acknowledged``: Indicates whether the bulk write was acknowledged | ||
- ``insertedCount``: The number of inserted documents | ||
- ``matchedCount``: The number of matched documents | ||
- ``modifiedCount``: The number of updated documents | ||
- ``upsertedCount``: The number of upserted documents | ||
- ``deletedCount``: The number of deleted documents | ||
- ``insertResults``: The results of each individual successful insert operation | ||
- ``updateResults``: The results of each individual successful update operation | ||
- ``deleteResults``: The results of each individual successful delete operation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put these in a table.
If any bulk write operations called on a collection are unsuccessful, | ||
the {+driver-short+} throws a ``MongoBulkWriteError`` and does not perform any further operations if the | ||
``ordered`` option is set to ``true``. If ``ordered`` is set to ``false``, it will | ||
attempt to continue with subsequent operations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a link to the Ordered vs Unordered section in the server manual.
https://www.mongodb.com/docs/manual/core/bulk-write-operations/#ordered-vs-unordered-operations
Bulk operations help reduce the number of calls to the server. Instead of sending | ||
a request for each operation, you can perform multiple operations within one action. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would put this line above the previous paragraph, and include a link to the Bulk Write Operations page in the server guide.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* DOCSP-44681: Client bulk write * more content * fixes * code format * edit overview * fix * RM feedback * fixes * DJ feedback (cherry picked from commit 483be06)
* DOCSP-44681: Client bulk write * more content * fixes * code format * edit overview * fix * RM feedback * fixes * DJ feedback (cherry picked from commit 483be06)
* DOCSP-44681: Client bulk write * more content * fixes * code format * edit overview * fix * RM feedback * fixes * DJ feedback (cherry picked from commit 483be06)
* DOCSP-44681: Client bulk write * more content * fixes * code format * edit overview * fix * RM feedback * fixes * DJ feedback (cherry picked from commit 483be06)
Pull Request Info
PR Reviewing Guidelines
JIRA - https://jira.mongodb.org/browse/DOCSP-44681
Staging - https://deploy-preview-984--docs-node.netlify.app/fundamentals/crud/write-operations/bulk/
Self-Review Checklist