Before writing below, first log into your cmd or PowerShell
TYPE: mongo //To get into MongoDB shell use <Your_dbName> //For Creating or making use of existing db
To list all collection names, use any of the following options: -
show collections //output every collection OR show tables OR db.getCollectionNames() //shows all collections as a list
To display the entire contents of the collections or data, use the code below that was sent by Bruno_Ferreira.
var collections = db.getCollectionNames(); for(var i = 0; i< collections.length; i++) { print('Collection: ' + collections[i]); // print the name of each collection db.getCollection(collections[i]).find().forEach(printjson); //and then print the json of each of its elements }
Amit Kumar Jun 06 '16 at 10:26 2016-06-06 10:26
source share