Je kunt doen...
JavaScript (shell):
db.getCollectionNames()
Node.js:
db.listCollections()
Niet-JavaScript (alleen shell):
show collections
De reden dat ik dat niet-JavaScript noem, is omdat:
$ 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"
]
Als je echt die lieve, lieve show collections
uitvoer, kunt u:
$ mongo prodmongo/app --eval "db.getCollectionNames().join('\n')"
MongoDB shell version: 3.2.10
connecting to: prodmongo/app
Profiles
Unit_Info