How to use db.getCollectionInfos() In MongoDB
Similarly, we can gather detailed information about collections using the db.getCollectionInfos() method.
When executed, this method returns an array of documents, each containing information about a specific collection, including its name, type, and options.
Example
Here, We gathered detailed information about collections in the current database via db.getCollectionInfos(), obtaining specifics like names, types, and options for each collection.
db.getCollectionInfos()
Output:
How to List All Collections in the MongoDB Shell?
Managing collections is a fundamental task in MongoDB database administration. Knowing how to list all collections in the MongoDB shell is essential for understanding your database structure and managing your data effectively. In this article, we’ll explore how to list all collections in the MongoDB shell and discuss why this knowledge is important for database administrators and developers.