BulkWriteCommand
final class BulkWriteCommand implements Countable (View source)
MongoDB\Driver\BulkWriteCommand collects one or more write operations that should be sent to the server using the ยป bulkWrite command introduced in MongoDB 8.0. After adding any number of insert, update, and delete operations, the command may be executed via MongoDB\Driver\Manager::executeBulkWriteCommand().
Unlike MongoDB\Driver\BulkWrite, where all write operations must target the same collection, each write operation within MongoDB\Driver\BulkWriteCommand may target a different collection.
Write operations may either be ordered (default) or unordered. Ordered write operations are sent to the server, in the order provided, for serial execution. If a write fails, any remaining operations will be aborted. Unordered operations are sent to the server in an arbitrary order where they may be executed in parallel. Any errors that occur are reported after all operations have been attempted.
Methods
Create a new BulkWriteCommand
Count number of write operations in the BulkWriteCommand
Add a deleteOne operation
Add a deleteMany operation
Add an insertOne operation
Add a replaceOne operation
Add an updateMany operation
Add an updateMany operation
Details
final
__construct(array|null $options = null)
Create a new BulkWriteCommand
int
count()
Count number of write operations in the BulkWriteCommand
final void
deleteOne(string $namespace, array|object $filter, array|null $options = null)
Add a deleteOne operation
final void
deleteMany(string $namespace, array|object $filter, array|null $options = null)
Add a deleteMany operation
final mixed
insertOne(string $namespace, array|object $document)
Add an insertOne operation
final void
replaceOne(string $namespace, array|object $filter, array|object $replacement, array|null $options = null)
Add a replaceOne operation
final void
updateOne(string $namespace, array|object $filter, array|object $update, array|null $options = null)
Add an updateMany operation
final void
updateMany(string $namespace, array|object $filter, array|object $update, array|null $options = null)
Add an updateMany operation