bulk – The bulk write operations interface
The bulk write operations interface.
New in version 2.7.
- class
pymongo.bulk.
BulkOperationBuilder
(collection, ordered=True, bypass_document_validation=False) - DEPRECATED: Initialize a new BulkOperationBuilder instance.
Parameters:
- collection: A
Collection
instance. - ordered (optional): If
True
all operations will be executedserially, in the order provided, and the entire execution willabort on the first error. IfFalse
operations will be executedin arbitrary order (possibly in parallel on the server), reportingany errors that occurred after attempting all operations. DefaultstoTrue
. - bypass_document_validation: (optional) If
True
, allows thewrite to opt-out of document level validation. Default isFalse
.
Note
bypass_document_validation requires server version>= 3.2
Changed in version 3.5: Deprecated. Use bulk_write()
instead.
Changed in version 3.2: Added bypass_document_validation support
Parameters:
- write_concern (optional): the write concern for this bulkexecution.
Parameters:
- _selector_ (dict): the selection criteria for updateand remove operations.
- _collation_ (optional): An instance of[<code>Collation</code>]($f10fec00031f6158.md#pymongo.collation.Collation). This option is onlysupported on MongoDB 3.4 and above.Returns:
- A [<code>BulkWriteOperation</code>](https://api.mongodb.com/python/current/api/pymongo/#pymongo.bulk.BulkWriteOperation) instance, used to addupdate and remove operations to this bulk operation.
Changed in version 3.4: Added the collation option.
Parameters:
- _document_ (dict): the document to insert
See also
Why does PyMongo add an _id field to all of my documents?
- class
pymongo.bulk.
BulkUpsertOperation
(selector, bulk, collation) An interface for adding upsert operations.
Parameters:
- _replacement_ (dict): the replacement document
Parameters:
- _update_ (dict): the update operations to apply
Parameters:
- _update_ (dict): the update operations to apply
- class
pymongo.bulk.
BulkWriteOperation
(selector, bulk, collation) An interface for adding update or remove operations.
Parameters:
- _replacement_ (dict): the replacement document
Parameters:
- _update_ (dict): the update operations to apply
Parameters:
- _update_ (dict): the update operations to apply
Returns:
- A [<code>BulkUpsertOperation</code>](https://api.mongodb.com/python/current/api/pymongo/#pymongo.bulk.BulkUpsertOperation) instance, used to addupdate operations to this bulk operation.