bulk
– 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 all operations will be executed serially, in the order provided, and the entire execution will abort on the first error. If
False
operations will be executed in arbitrary order (possibly in parallel on the server), reporting any errors that occurred after attempting all operations. Defaults to .bypass_document_validation: (optional) If
True
, allows the write to opt-out of document level validation. Default is .
Note
bypass_document_validation requires server version >= 3.2
Changed in version 3.5: Deprecated. Use instead.
Changed in version 3.2: Added bypass_document_validation support
execute(write_concern=None)
Execute all provided operations.
Parameters
- write_concern (optional): the write concern for this bulk execution.
find(selector, collation=None)
Specify selection criteria for bulk operations.
Parameters
collation (optional): An instance of Collation. This option is only supported on MongoDB 3.4 and above.
Returns
- A instance, used to add update and remove operations to this bulk operation.
Changed in version 3.4: Added the collation option.
class pymongo.bulk.BulkUpsertOperation(selector, bulk, collation)
An interface for adding upsert operations.
replace_one(replacement)
Replace one entire document matching the selector criteria.
Parameters
- replacement (dict): the replacement document
update(update)
Update all documents matching the selector.
Parameters
- update (dict): the update operations to apply
update_one(update)
Parameters
- update (dict): the update operations to apply
class pymongo.bulk.BulkWriteOperation(selector, bulk, collation)
An interface for adding update or remove operations.
remove()
Remove all documents matching the selector criteria.
replace_one(replacement)
Replace one entire document matching the selector criteria.
Parameters
- replacement (dict): the replacement document
update(update)
Update all documents matching the selector criteria.
Parameters
- update (dict): the update operations to apply
update_one(update)
Update one document matching the selector criteria.
Parameters
- update (dict): the update operations to apply
upsert()
Returns
- A BulkUpsertOperation instance, used to add update operations to this bulk operation.