New in version 2.1.
Definition
MongoDB\ClientBulkWrite::withCollection()Return an updated instance of
MongoDB\ClientBulkWritefrom the providedMongoDB\Collectioninstance. This method allows you to add subsequent write operations on a different collection than that with which theClientBulkWritewas created.This method does not build a new BulkWriteCommand and does not edit the
ClientBulkWriteinstance in place.function withCollection( Collection $collection, ): self You cannot mix
Collectioninstances associated with differentManagerobjects when calling this method on aClientBulkWriteinstance. This is because the library sends the completedBulkWriteCommandto a single server.
Parameters
$collection:MongoDB\Collection- The
Collectioninstance to set as the target for write operations added to theClientBulkWriteinstance after callingwithCollection().
Return Values
A new ClientBulkWrite instance with the same BulkWriteCommand
specification but an updated target namespace.
Errors/Exceptions
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).
See Also
Client Bulk Write section of the Bulk Write Operations guide