I want to list all the collection, created under my database. I know the query
db.getCollectionNames();
But it listing only – [ “system.indexes”, “system.users” ]
I tried
show collections
it listed following – system.indexes, system.users
It is not showing me my collections. How can i see all my collections ?
To see all the collections in the current database using the
mongoshell:db.getCollectionNames()returns the collections in the current database as a JavaScript arrayshow collectionsprints the collections in the current database as a listIf you aren’t seeing the expected collections, you can check the current database with:
If you want to see all collections in all databases, here’s some JavaScript that should do the trick: