display collection in mongodb code example
Example 1: show collections in mongodb
db.getCollectionNames()
Example 2: list all collections in the MongoDB shell
JavaScript (shell):
db.getCollectionNames()
Node.js:
db.listCollections()
Example 3: create collection in mongodb stack overflow
> use testdb
switched to db testdb
> db.createCollection("testcollection")
{ "ok" : 1 }
> db.getCollectionNames()
[ "system.indexes", "testcollection" ]
>