InsertMany
in package
implements
Executable
Operation for inserting multiple documents with the insert command.
Tags
Interfaces, Classes, Traits and Enums
- Executable
Table of Contents
- $collectionName : string
- $databaseName : string
- $documents : array<string|int, object>|array<string|int, array<string|int, mixed>>
- $options : array<string|int, mixed>
- __construct() : mixed
- Constructs an insert command.
- execute() : InsertManyResult
- 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.
Properties
$collectionName
private
string
$collectionName
$databaseName
private
string
$databaseName
$documents
private
array<string|int, object>|array<string|int, array<string|int, mixed>>
$documents
$options
private
array<string|int, mixed>
$options
Methods
__construct()
Constructs an insert command.
public
__construct(string $databaseName, string $collectionName, array<string|int, array<string|int, mixed>>|array<string|int, object> $documents[, array<string|int, mixed> $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
- $databaseName : string
-
Database name
- $collectionName : string
-
Collection name
- $documents : array<string|int, array<string|int, mixed>>|array<string|int, object>
-
List of documents to insert
- $options : array<string|int, mixed> = []
-
Command options
Tags
Return values
mixed —execute()
Execute the operation.
public
execute(Server $server) : InsertManyResult
Parameters
- $server : Server
Tags
Return values
InsertManyResult —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>