Listing Collections — MongoDB Technical Interview Questions & Answers
show collections and db.getCollectionNames().
Listing Collections
- Simple meaning: show collections lists collection names in the current database.
- How to use: use college then show collections or db.getCollectionNames().
- Try this: after insertOne, list collections — students should appear.
- Common mistake: show collections without use — you are on another DB.
- Interview tip: Shell helper + getCollectionNames().
Technical Interview Tip: use db, then show collections.
Code Examples for Listing Collections
Listing Collections — working example
show collections
db.getCollectionNames()Listing Collections — show collections / getCollectionNames() list collections in the current database.
How to Explain Listing Collections to an Interviewer
How do you list collections?
show collections db.getCollectionNames()