MongoDB: db.getCollectionNames() method
db.getCollectionNames
The db.getCollectionNames() method is used to return an array containing the names of all collections in the current database.
Syntax:
db.getCollectionNames()
Example: MongoDB: db.getCollectionNames() method
The following example will return the name of the collection form the current database test.
db.getCollectionNames();
Output
> db.getCollectionNames(); [ "collection_new", "empdetails", "invoice", "orders", "prod_mast", "prod_master", "restaurants", "restaurants_new", "system.indexes", "system.profile", "userdetails" ]
Retrieve the restaurants data from here
Previous:
db.getCollection() method
Next:
db.getLastError() method
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join