Operation for inserting multiple documents with the insert command.
- Full name:
\MongoDB\Operation\InsertMany
- This class implements:
\MongoDB\Operation\Executable
See Also:
- \MongoDB\Collection::insertMany() -
- http://docs.mongodb.org/manual/reference/command/insert/ -
private string $databaseName
private string $collectionName
private object[]|array[] $documents
private array $options
Constructs an insert command.
public __construct(string $databaseName, string $collectionName, array[]|object[] $documents, array $options = []): mixed
Supported options:
-
bypassDocumentValidation (boolean): If true, allows the write to circumvent document level validation.
-
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:
Parameter | Type | Description |
---|---|---|
$databaseName |
string | Database name |
$collectionName |
string | Collection name |
$documents |
array[]|object[] | List of documents to insert |
$options |
array | Command options |
Execute the operation.
public execute(\MongoDB\Driver\Server $server): \MongoDB\InsertManyResult
Parameters:
Parameter | Type | Description |
---|---|---|
$server |
\MongoDB\Driver\Server |
See Also:
- \MongoDB\Operation\Executable::execute() -
Create options for constructing the bulk write.
private createBulkWriteOptions(): array
See Also:
Create options for executing the bulk write.
private createExecuteOptions(): array
See Also: