Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Docs Menu
Docs Home
/ / /
PHP Library Manual
/ /

MongoDB\ClientBulkWrite::createWithCollection()

New in version 2.1.

MongoDB\ClientBulkWrite::createWithCollection()

Create an instance of the MongoDB\ClientBulkWrite builder from the provided MongoDB\Collection instance. You can add write operations to the ClientBulkWrite to create a new BulkWriteCommand that the library sends to the server.

function createWithCollection(
Collection $collection,
array $options = []
): self
$collection : MongoDB\Collection
The Collection instance to set as the target for bulk write operations.
$options : array

An array specifying the desired options.

Name
Type
Description

bypassDocumentValidation

boolean

If true: the write operation ignores document level validation.

The default is false.

comment

mixed

Enables users to specify an arbitrary comment to help trace the operation through the database profiler, currentOp output, and logs.

let

array|object

Map of parameter names and values. Values must be constant or closed expressions that do not reference document fields. Parameters can then be accessed as variables in an aggregate expression context (e.g. $$var).

This feature is not supported for MongoDB server versions 6.0 and earlier. If used, the server returns an exception at execution time.

ordered

boolean

If true: When a single write fails, the operation stops without performing the remaining writes and throws an exception.

If false: When a single write fails, the operation continues with the remaining writes, if any, and throws an exception.

The default is true.

verboseResults

boolean

Specifies whether to return verbose results.

The default is false.

A new ClientBulkWrite instance with an empty BulkWriteCommand specification.

MongoDB\Exception\UnsupportedException if options are used and not supported by the selected server (e.g. collation, readConcern, writeConcern).

MongoDB\Exception\InvalidArgumentException for errors related to the parsing of parameters or options.

MongoDB\Driver\Exception\RuntimeException for other errors at the extension level (e.g. connection errors).

  • Client Bulk Write section of the Bulk Write Operations guide

Back

MongoDB\ClientBulkWrite

On this page