Anda bisa melakukan...
JavaScript (kulit):
db.getCollectionNames()
Node.js:
db.listCollections()
Non-JavaScript (hanya shell):
show collections
Alasan saya menyebutnya non-JavaScript adalah karena:
$ mongo prodmongo/app --eval "show collections"
MongoDB shell version: 3.2.10
connecting to: prodmongo/app
2016-10-26T19:34:34.886-0400 E QUERY [thread1] SyntaxError: missing ; before statement @(shell eval):1:5
$ mongo prodmongo/app --eval "db.getCollectionNames()"
MongoDB shell version: 3.2.10
connecting to: prodmongo/app
[
"Profiles",
"Unit_Info"
]
Jika Anda benar-benar menginginkan show collections
yang manis dan manis itu keluaran, Anda dapat:
$ mongo prodmongo/app --eval "db.getCollectionNames().join('\n')"
MongoDB shell version: 3.2.10
connecting to: prodmongo/app
Profiles
Unit_Info