Skip to content

Latest commit

 

History

History
284 lines (111 loc) · 3.21 KB

BulkWriteResult.md

File metadata and controls

284 lines (111 loc) · 3.21 KB

BulkWriteResult

Result class for a bulk write operation.

  • Full name: \MongoDB\BulkWriteResult

Properties

writeResult

private \MongoDB\Driver\WriteResult $writeResult

insertedIds

private array $insertedIds

isAcknowledged

private bool $isAcknowledged

Methods

__construct

public __construct(\MongoDB\Driver\WriteResult $writeResult, array $insertedIds): mixed

Parameters:

Parameter Type Description
$writeResult \MongoDB\Driver\WriteResult
$insertedIds array

getDeletedCount

Return the number of documents that were deleted.

public getDeletedCount(): int

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

See Also:

  • \MongoDB\BulkWriteResult::isAcknowledged() -

getInsertedCount

Return the number of documents that were inserted.

public getInsertedCount(): int

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

See Also:

  • \MongoDB\BulkWriteResult::isAcknowledged() -

getInsertedIds

Return a map of the inserted documents' IDs.

public getInsertedIds(): array

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.


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.

See Also:

  • \MongoDB\BulkWriteResult::isAcknowledged() -

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.

See Also:

  • \MongoDB\BulkWriteResult::isAcknowledged() -

getUpsertedCount

Return the number of documents that were upserted.

public getUpsertedCount(): int

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

See Also:

  • \MongoDB\BulkWriteResult::isAcknowledged() -

getUpsertedIds

Return a map of the upserted documents' IDs.

public getUpsertedIds(): array

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.

See Also:

  • \MongoDB\BulkWriteResult::isAcknowledged() -

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.