MongoDBInsertManyResult-getInsertedIds.txt 1.01 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
===========================================
MongoDB\\InsertManyResult::getInsertedIds()
===========================================

.. default-domain:: mongodb

.. contents:: On this page
   :local:
   :backlinks: none
   :depth: 1
   :class: singlecol

Definition
----------

.. phpmethod:: MongoDB\\InsertManyResult::getInsertedIds()

   Return a map of IDs (i.e. ``_id`` field values) for the inserted documents.

   .. code-block:: php

      function getInsertedIds(): array

   Since IDs are created by the driver, this method may be called irrespective
   of whether the write was acknowledged.

Return Values
-------------

A map of IDs (i.e. ``_id`` field values) for the inserted documents.

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
35
driver-generated ID will be a :php:`MongoDB\\BSON\\ObjectId
36
<class.mongodb-bson-objectid>` instance.