Quantcast
Channel: CodeFari
Viewing all articles
Browse latest Browse all 265

How to list all collections in the MongoDB

$
0
0


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

Viewing all articles
Browse latest Browse all 265

Trending Articles