MongoDB\BulkWriteResult::getUpsertedIds()

For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt

MongoDB\BulkWriteResult::getUpsertedIds()

Definition

Return a map of IDs (i.e. _id field values) for documents that were upserted by all update and replace operations in the bulk write.

function getUpsertedIds(): array

Return Values

A map of IDs (i.e. _id field values) for documents that were upserted by all update and replace operations in the bulk write.

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 upserting (i.e. the server did not generate an ID), the index will contain its _id field value. Any server-generated ID will be a MongoDB\BSON\ObjectId instance.

Errors/Exceptions

[MongoDB\Exception\BadMethodCallException](https://www.mongodb.com/docs/php-library/current/reference/exception-classes.md#mongodb-phpclass-phpclass.MongoDB-Exception-BadMethodCallException if this method is called and the write operation used an unacknowledged write concern.

See Also