Documentation

InsertMany
in package

FinalYes

Operation for inserting multiple documents with the insert command.

Tags
see
Collection::insertMany()
see
https://mongodb.com/docs/manual/reference/command/insert/

Table of Contents

Properties

$collectionName  : string
$databaseName  : string
$documents  : array<int, object|array<string|int, mixed>>
$options  : array<string|int, mixed>

Methods

__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.
validateDocuments()  : array<int, object|array<string|int, mixed>>

Properties

$documents

private array<int, object|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<int, object|array<string|int, mixed>> $documents[, array<string|int, mixed> $options = [] ]) : mixed

Supported options:

  • bypassDocumentValidation (boolean): If true, allows the write to circumvent document level validation.

  • codec (MongoDB\Codec\DocumentCodec): Codec used to encode PHP objects into BSON.

  • comment (mixed): BSON value to attach as a comment to the command(s) associated with this insert.

    This is not supported for servers versions < 4.4.

  • 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<int, object|array<string|int, mixed>>

List of documents to insert

$options : array<string|int, mixed> = []

Command options

Tags
throws
InvalidArgumentException

for parameter/option parsing errors

validateDocuments()

private validateDocuments(array<int, object|array<string|int, mixed>> $documents, DocumentCodec|null $codec) : array<int, object|array<string|int, mixed>>
Parameters
$documents : array<int, object|array<string|int, mixed>>
$codec : DocumentCodec|null
Return values
array<int, object|array<string|int, mixed>>

        
On this page

Search results