Basic MongoDB Commands
Useful Commands for MongoDB
1 min readFeb 8, 2018
Press enter or click to view image in full size![]()
GET ALL DATABASES
show dbsGET ALL COLLECTIONS
mongo shell:
db.getCollectionNames()node.js:
db.listCollections()Get Rio Weber’s stories in your inbox
Join Medium for free to get updates from this writer.
bash:
show collectionsEXPORT A COLLECTION
bash:
mongoexport --db DATABASE --collection NAME --out FILE_OUT.jsonIMPORT A COLLECTION
bash:
mongoimport --db DATABASE --collection NAME < FILE_IN.json








