Skip to content

Instantly share code, notes, and snippets.

@jonathanwork
Created January 3, 2017 05:24
Show Gist options
  • Save jonathanwork/7ba75b055fc5e25efab209b6ad46330c to your computer and use it in GitHub Desktop.
Save jonathanwork/7ba75b055fc5e25efab209b6ad46330c to your computer and use it in GitHub Desktop.
this will look into all your collections within mongoDB
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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment