MongoDB\Driver\Server::executeBulkWriteCommand
(mongodb >=2.1.0)
MongoDB\Driver\Server::executeBulkWriteCommand — Execute write operations on this server using the bulkWrite command
说明
$bulk, ?array $options = null): MongoDB\Driver\BulkWriteCommandResultExecutes one or more write operations on this server using the » bulkWrite command introduced in MongoDB 8.0.
A MongoDB\Driver\BulkWriteCommand can be constructed with one or more write operations of varying types (e.g. inserts, updates, and deletes). Each write operation may target a different collection.
The default value for the "writeConcern" option will be
inferred from an active transaction (indicated by the
"session" option), followed by the
connection URI.
参数
bulk(MongoDB\Driver\BulkWriteCommand)-
The write(s) to execute.
options-
options Option Type Description session MongoDB\Driver\Session A session to associate with the operation.
writeConcern MongoDB\Driver\WriteConcern A write concern to apply to the operation.
返回值
Returns MongoDB\Driver\BulkWriteCommandResult on success.
错误/异常
- Throws MongoDB\Driver\Exception\InvalidArgumentException if
bulkdoes not contain any write operations. - Throws MongoDB\Driver\Exception\InvalidArgumentException if
bulkhas already been executed. MongoDB\Driver\BulkWriteCommand objects may not be executed multiple times. - Throws MongoDB\Driver\Exception\InvalidArgumentException if the
"session"option is used in combination with an unacknowledged write concern. - Throws MongoDB\Driver\Exception\InvalidArgumentException on argument parsing errors.
- Throws MongoDB\Driver\Exception\ConnectionException if connection to the server fails (for reasons other than authentication).
- Throws MongoDB\Driver\Exception\AuthenticationException if authentication is needed and fails.
- Throws MongoDB\Driver\Exception\BulkWriteCommandException on any write failure (e.g. command failure, write or write concern error)
- Throws MongoDB\Driver\Exception\RuntimeException on other errors.
参见
- MongoDB\Driver\BulkWriteCommand
- MongoDB\Driver\BulkWriteCommandResult
- MongoDB\Driver\WriteConcern
- MongoDB\Driver\Manager::executeBulkWriteCommand() - Execute write operations using the bulkWrite command