bulk – The bulk write operations interface
The bulk write operations interface.
-
class pymongo.bulk.BulkOperationBuilder(collection, ordered=True)
Initialize a new BulkOperationBuilder instance.
Parameters: |
- collection: A Collection instance.
- ordered (optional): If True 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 True.
|
Warning
If you are using a version of MongoDB older than 2.6 you will
get much better bulk insert performance using
insert().
-
execute(write_concern=None)
Execute all provided operations.
Parameters: |
- write_concern (optional): the write concern for this bulk
execution.
|
-
find(selector)
Specify selection criteria for bulk operations.
Parameters: |
- selector (dict): the selection criteria for update
and remove operations.
|
Returns: |
- A BulkWriteOperation instance, used to add
update and remove operations to this bulk operation.
|
-
insert(document)
Insert a single document.
Parameters: |
- document (dict): the document to insert
|
-
class pymongo.bulk.BulkUpsertOperation(selector, bulk)
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)
Update one document matching the selector.
Parameters: |
- update (dict): the update operations to apply
|
-
class pymongo.bulk.BulkWriteOperation(selector, bulk)
An interface for adding update or remove operations.
-
remove()
Remove all documents matching the selector criteria.
-
remove_one()
Remove a single document 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()
Specify that all chained update operations should be
upserts.