@@ -210,8 +210,10 @@ that failed, and details about the exception.
210
210
.. note::
211
211
212
212
When {+driver-short+} runs a bulk operation, it uses the ``write_concern`` of the
213
- collection in which the operation is running. The driver reports all write
214
- concern errors after attempting all operations, regardless of execution order.
213
+ collection or client on which the operation is running. You can also set
214
+ a write concern for the operation when using the ``MongoClient.bulk_write()``
215
+ method. The driver reports all write concern errors after attempting all operations,
216
+ regardless of execution order.
215
217
216
218
.. _pymongo-bulk-write-collection-ex:
217
219
@@ -248,15 +250,16 @@ instance:
248
250
.. io-code-block::
249
251
250
252
.. input:: /includes/write/bulk-write.py
251
- :start-after: start-bulk-write-mixed-collection
252
- :end-before: end-bulk-write-mixed-collection
253
+ :start-after: start-bulk-write-mixed-client
254
+ :end-before: end-bulk-write-mixed-client
253
255
:language: python
254
256
255
257
.. output::
256
258
257
- ClientBulkWriteResult({'writeErrors': [], 'writeConcernErrors': [], 'nInserted': 2,
258
- 'nUpserted': 0, 'nMatched': 2, 'nModified': 2, 'nRemoved': 1, 'upserted': []},
259
- acknowledged=True)
259
+ ClientBulkWriteResult({'anySuccessful': True, 'error': None, 'writeErrors': [],
260
+ 'writeConcernErrors': [], 'nInserted': 1, 'nUpserted': 0, 'nMatched': 1,
261
+ 'nModified': 1, 'nDeleted': 344, 'insertResults': {}, 'updateResults': {},
262
+ 'deleteResults': {}}, acknowledged=True, verbose=False)
260
263
261
264
Customize Bulk Write Operations
262
265
-------------------------------
@@ -388,12 +391,24 @@ The following example calls the ``bulk_write()`` method from the preceding
388
391
:ref:`pymongo-bulk-write-client-ex` but sets the ``verbose_results`` option
389
392
to ``True``:
390
393
391
- .. literalinclude:: /includes/write/bulk-write.py
392
- :start-after: start-bulk-write-verbose
393
- :end-before: end-bulk-write-verbose
394
- :language: python
394
+ .. io-code-block::
395
395
:copyable:
396
396
397
+ .. input:: /includes/write/bulk-write.py
398
+ :start-after: start-bulk-write-verbose
399
+ :end-before: end-bulk-write-verbose
400
+ :language: python
401
+
402
+ .. output::
403
+ :visible: false
404
+
405
+ ClientBulkWriteResult({'anySuccessful': True, 'error': None, 'writeErrors': [],
406
+ 'writeConcernErrors': [], 'nInserted': 1, 'nUpserted': 0, 'nMatched': 1, 'nModified': 1,
407
+ 'nDeleted': 344, 'insertResults': {0: InsertOneResult(ObjectId('...'),
408
+ acknowledged=True)}, 'updateResults': {1: UpdateResult({'ok': 1.0, 'idx': 1, 'n': 1,
409
+ 'nModified': 1}, acknowledged=True)}, 'deleteResults': {2: DeleteResult({'ok': 1.0,
410
+ 'idx': 2, 'n': 344}, acknowledged=True)}}, acknowledged=True, verbose=True)
411
+
397
412
Return Values
398
413
-------------
399
414
@@ -448,7 +463,7 @@ The ``Collection.bulk_write()`` method returns a ``BulkWriteResult`` object. The
448
463
Client Bulk Write Return Value
449
464
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
450
465
451
- The ``Client .bulk_write()`` method returns a ``ClientBulkWriteResult`` object. The
466
+ The ``MongoClient .bulk_write()`` method returns a ``ClientBulkWriteResult`` object. The
452
467
``ClientBulkWriteResult`` object contains the following properties:
453
468
454
469
.. list-table::
0 commit comments