Result class for a bulk write operation.
- Full name:
\MongoDB\BulkWriteResult
private \MongoDB\Driver\WriteResult $writeResult
private array $insertedIds
private bool $isAcknowledged
public __construct(\MongoDB\Driver\WriteResult $writeResult, array $insertedIds): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$writeResult |
\MongoDB\Driver\WriteResult | |
$insertedIds |
array |
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() -
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() -
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.
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() -
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() -
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() -
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() -
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.