1

I'm trying to get the index of a collection.

> db.version()
3.2.6

> db.getCollectionNames()
[ "last_aggregated_stat_ids", "mapps", "stats", "system.indexes" ]

> db.mapps.getIndexes()
[
    {
        "v" : 1,
        "key" : {
            "_id" : 1
        },
        "name" : "_id_",
        "ns" : "app_development.mapps"
    }
]

> db.stats.getIndexes()
2016-07-20T16:51:04.601+0200 E QUERY    [thread1] TypeError: db.stats.getIndexes is not a function :
@(shell):1:1

Any ideas of what can happen?

2

db.stats() is a function call so db.stats is a function reference which has no function called getIndexes().

To get them db.getCollection("stats").getIndexes()

https://docs.mongodb.com/manual/reference/method/db.stats/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.