mongosh appdb --eval 'db.users.getIndexes()'

Category: Databases & SQL

mongosh appdb --eval 'db.users.getIndexes()'

List indexes on a collection

Prints every index on users, including the automatic _id index, with its keys and options. Review this before creating new indexes to avoid duplicates. Related: db.users.dropIndex().
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.