BulkWrite
in package
implements
Executable
Operation for executing multiple write operations.
Tags
Interfaces, Classes, Traits and Enums
- Executable
Table of Contents
- DELETE_MANY = 'deleteMany'
- DELETE_ONE = 'deleteOne'
- INSERT_ONE = 'insertOne'
- REPLACE_ONE = 'replaceOne'
- UPDATE_MANY = 'updateMany'
- UPDATE_ONE = 'updateOne'
- $collectionName : string
- $databaseName : string
- $operations : array<string|int, array<string|int, mixed>>
- $options : array<string|int, mixed>
- __construct() : mixed
- Constructs a bulk write operation.
- execute() : BulkWriteResult
- Execute the operation.
- createBulkWriteOptions() : array<string|int, mixed>
- Create options for constructing the bulk write.
- createExecuteOptions() : array<string|int, mixed>
- Create options for executing the bulk write.
Constants
DELETE_MANY
public
mixed
DELETE_MANY
= 'deleteMany'
DELETE_ONE
public
mixed
DELETE_ONE
= 'deleteOne'
INSERT_ONE
public
mixed
INSERT_ONE
= 'insertOne'
REPLACE_ONE
public
mixed
REPLACE_ONE
= 'replaceOne'
UPDATE_MANY
public
mixed
UPDATE_MANY
= 'updateMany'
UPDATE_ONE
public
mixed
UPDATE_ONE
= 'updateOne'
Properties
$collectionName
private
string
$collectionName
$databaseName
private
string
$databaseName
$operations
private
array<string|int, array<string|int, mixed>>
$operations
$options
private
array<string|int, mixed>
$options
Methods
__construct()
Constructs a bulk write operation.
public
__construct(string $databaseName, string $collectionName, array<string|int, array<string|int, mixed>> $operations[, array<string|int, mixed> $options = [] ]) : mixed
Example array structure for all supported operation types:
[ [ 'deleteMany' => [ $filter, $options ] ], [ 'deleteOne' => [ $filter, $options ] ], [ 'insertOne' => [ $document ] ], [ 'replaceOne' => [ $filter, $replacement, $options ] ], [ 'updateMany' => [ $filter, $update, $options ] ], [ 'updateOne' => [ $filter, $update, $options ] ], ]
Arguments correspond to the respective Operation classes; however, the writeConcern option is specified for the top-level bulk write operation instead of each individual operation.
Supported options for deleteMany and deleteOne operations:
- collation (document): Collation specification.
Supported options for replaceOne, updateMany, and updateOne operations:
-
collation (document): Collation specification.
-
upsert (boolean): When true, a new document is created if no document matches the query. The default is false.
Supported options for updateMany and updateOne operations:
- arrayFilters (document array): A set of filters specifying to which array elements an update should apply.
Supported options for the bulk write operation:
-
bypassDocumentValidation (boolean): If true, allows the write to circumvent document level validation. The default is false.
-
ordered (boolean): If true, when an insert fails, return without performing the remaining writes. If false, when a write fails, continue with the remaining writes, if any. The default is true.
-
session (MongoDB\Driver\Session): Client session.
-
writeConcern (MongoDB\Driver\WriteConcern): Write concern.
Parameters
- $databaseName : string
-
Database name
- $collectionName : string
-
Collection name
- $operations : array<string|int, array<string|int, mixed>>
-
List of write operations
- $options : array<string|int, mixed> = []
-
Command options
Tags
Return values
mixed —execute()
Execute the operation.
public
execute(Server $server) : BulkWriteResult
Parameters
- $server : Server
Tags
Return values
BulkWriteResult —createBulkWriteOptions()
Create options for constructing the bulk write.
private
createBulkWriteOptions() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —createExecuteOptions()
Create options for executing the bulk write.
private
createExecuteOptions() : array<string|int, mixed>