Nov 9, 2015

How to list all collections in the MongoDB



getCollectionNames() Function use to list all collections in MongoDB.
Syntax

db. getCollectionNames()

it will return all the collection from db.

Example

db.getCollectionNames()
Output

[ "collection1", "collection2", "system.indexes" ]

Like this if you want see only collections, then use following 

show collections

Output

Collection1
Collection2
System.Indexes