PHP Classes

File: vendor/mongodb/mongodb/docs/reference/method/MongoDBCollection-listIndexes.txt

Recommend this page to a friend!
  Classes of walid laggoune   MongoDB Queue PHP Query Execute   vendor/mongodb/mongodb/docs/reference/method/MongoDBCollection-listIndexes.txt   Download  
File: vendor/mongodb/mongodb/docs/reference/method/MongoDBCollection-listIndexes.txt
Role: Documentation
Content type: text/plain
Description: Documentation
Class: MongoDB Queue PHP Query Execute
Query and execute multiple queries using MongoDB
Author: By
Last change:
Date: 4 years ago
Size: 2,495 bytes
 

Contents

Class file image Download
================================== MongoDB\\Collection::listIndexes() ================================== .. default-domain:: mongodb .. contents:: On this page :local: :backlinks: none :depth: 1 :class: singlecol Definition ---------- .. phpmethod:: MongoDB\\Collection::listIndexes() Returns information for all indexes for this collection. .. code-block:: php function listIndexes(array $options = []): MongoDB\Model\IndexInfoIterator This method has the following parameters: .. include:: /includes/apiargs/MongoDBCollection-method-listIndexes-param.rst The ``$options`` parameter supports the following options: .. include:: /includes/apiargs/MongoDBCollection-method-listIndexes-option.rst Return Values ------------- A traversable :phpclass:`MongoDB\\Model\\IndexInfoIterator`, which contains a :phpclass:`MongoDB\\Model\\IndexInfo` object for each index for the collection. Errors/Exceptions ----------------- .. include:: /includes/extracts/error-invalidargumentexception.rst .. include:: /includes/extracts/error-driver-runtimeexception.rst Example ------- The following example lists all of the indexes for the ``restaurants`` collection in the ``test`` database: .. code-block:: php <?php $collection = (new MongoDB\Client)->test->restaurants; foreach ($collection->listIndexes() as $index) { var_dump($index); } The output would then resemble:: object(MongoDB\Model\IndexInfo)#8 (4) { ["v"]=> int(1) ["key"]=> array(1) { ["_id"]=> int(1) } ["name"]=> string(4) "_id_" ["ns"]=> string(16) "test.restaurants" } object(MongoDB\Model\IndexInfo)#12 (4) { ["v"]=> int(1) ["key"]=> array(1) { ["cuisine"]=> float(-1) } ["name"]=> string(10) "cuisine_-1" ["ns"]=> string(16) "test.restaurants" } object(MongoDB\Model\IndexInfo)#8 (4) { ["v"]=> int(1) ["key"]=> array(1) { ["borough"]=> float(1) } ["name"]=> string(9) "borough_1" ["ns"]=> string(16) "test.restaurants" } See Also -------- - :doc:`/tutorial/indexes` - :manual:`listIndexes </reference/command/listIndexes>` command reference in the MongoDB manual - :manual:`Index documentation </core/indexes>` in the MongoDB manual - `Enumerating Collections <https://github.com/mongodb/specifications/blob/master/source/enumerate-indexes.rst>`_ specification