- Reference >
mongo
Shell Methods >- Collection Methods >
- db.collection.getIndexes()
db.collection.getIndexes()¶
On this page
Definition¶
-
db.collection.
getIndexes
()¶ Returns an array that holds a list of documents that identify and describe the existing indexes on the collection. You must call
db.collection.getIndexes()
on a collection. For example:db.collection.getIndexes()
Change
collection
to the name of the collection for which to return index information.
Considerations¶
Changed in version 3.0.0.
For MongoDB 3.0 deployments using the WiredTiger storage engine, if you run db.collection.getIndexes()
from a
version of the mongo
shell before 3.0 or a version of the
driver prior to 3.0 compatible version, db.collection.getIndexes()
will return no data, even if
there are existing indexes. For more information, see
WiredTiger and Driver Version Compatibility.
Required Access¶
The user executing the method requires either find
privileges on the system.indexes
collection or the
listIndexes
privilege action. At a minimum, the
read
built-in role provide
the requisite permissions.
Output¶
db.collection.getIndexes()
returns an array of documents that
hold index information for the collection. Index information includes
the keys and options used to create the index. For information on the
keys and index options, see db.collection.createIndex()
.