Documentation

BulkWriteResult
in package

Result class for a bulk write operation.

Table of Contents

$insertedIds  : array<string|int, mixed>
$isAcknowledged  : bool
$writeResult  : WriteResult
__construct()  : mixed
getDeletedCount()  : int
Return the number of documents that were deleted.
getInsertedCount()  : int
Return the number of documents that were inserted.
getInsertedIds()  : array<string|int, mixed>
Return a map of the inserted documents' IDs.
getMatchedCount()  : int
Return the number of documents that were matched by the filter.
getModifiedCount()  : int|null
Return the number of documents that were modified.
getUpsertedCount()  : int
Return the number of documents that were upserted.
getUpsertedIds()  : array<string|int, mixed>
Return a map of the upserted documents' IDs.
isAcknowledged()  : bool
Return whether this update was acknowledged by the server.

Properties

Methods

__construct()

public __construct(WriteResult $writeResult, array<string|int, mixed> $insertedIds) : mixed
Parameters
$writeResult : WriteResult
$insertedIds : array<string|int, mixed>
Return values
mixed

getDeletedCount()

Return the number of documents that were deleted.

public getDeletedCount() : int

This method should only be called if the write was acknowledged.

Tags
see
BulkWriteResult::isAcknowledged()
throws
BadMethodCallException

is the write result is unacknowledged

Return values
int

getInsertedCount()

Return the number of documents that were inserted.

public getInsertedCount() : int

This method should only be called if the write was acknowledged.

Tags
see
BulkWriteResult::isAcknowledged()
throws
BadMethodCallException

is the write result is unacknowledged

Return values
int

getInsertedIds()

Return a map of the inserted documents' IDs.

public getInsertedIds() : array<string|int, mixed>

The index of each ID in the map corresponds to each document's position in the bulk operation. If a document had an ID prior to inserting (i.e. the driver did not generate an ID), the index will contain its "_id" field value. Any driver-generated ID will be a MongoDB\BSON\ObjectId instance.

Return values
array<string|int, mixed>

getMatchedCount()

Return the number of documents that were matched by the filter.

public getMatchedCount() : int

This method should only be called if the write was acknowledged.

Tags
see
BulkWriteResult::isAcknowledged()
throws
BadMethodCallException

is the write result is unacknowledged

Return values
int

getModifiedCount()

Return the number of documents that were modified.

public getModifiedCount() : int|null

This value is undefined (i.e. null) if the write executed as a legacy operation instead of command.

This method should only be called if the write was acknowledged.

Tags
see
BulkWriteResult::isAcknowledged()
throws
BadMethodCallException

is the write result is unacknowledged

Return values
int|null

getUpsertedCount()

Return the number of documents that were upserted.

public getUpsertedCount() : int

This method should only be called if the write was acknowledged.

Tags
see
BulkWriteResult::isAcknowledged()
throws
BadMethodCallException

is the write result is unacknowledged

Return values
int

getUpsertedIds()

Return a map of the upserted documents' IDs.

public getUpsertedIds() : array<string|int, mixed>

The index of each ID in the map corresponds to each document's position in bulk operation. If a document had an ID prior to upserting (i.e. the server did not need to generate an ID), this will contain its "_id". Any server-generated ID will be a MongoDB\BSON\ObjectId instance.

This method should only be called if the write was acknowledged.

Tags
see
BulkWriteResult::isAcknowledged()
throws
BadMethodCallException

is the write result is unacknowledged

Return values
array<string|int, mixed>

isAcknowledged()

Return whether this update was acknowledged by the server.

public isAcknowledged() : bool

If the update was not acknowledged, other fields from the WriteResult (e.g. matchedCount) will be undefined.

Return values
bool

Search results