Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB Show all contents from all collections

Is it possible to show all collections and its contents in MongoDB?

Is the only way to show one by one?

like image 437
Reno Avatar asked Jul 27 '14 21:07

Reno


People also ask

How do I show all collection data in MongoDB?

To get stats about MongoDB server, type the command db. stats() in MongoDB client. This will show the database name, number of collection and documents in the database.

How fetch all data from collection in MongoDB?

Fetch all data from the collection If we want to fetch all documents from the collection the following mongodb command can be used : >db. userdetails. find(); or >db.

Which command is used to display all the documents in the collection of a database?

In MongoDB, you can use the show dbs command to list all databases on a MongoDB server. This will show you the database name, as well as the size of the database in gigabytes.

What does find () do in MongoDB?

Find() Method. In MongoDB, find() method is used to select documents in a collection and return a cursor to the selected documents.


1 Answers

Once you are in terminal/command line, access the database/collection you want to use as follows:

show dbs use <db name> show collections 

choose your collection and type the following to see all contents of that collection:

db.collectionName.find() 

More info here on the MongoDB Quick Reference Guide.

like image 58
sharkySharks Avatar answered Sep 22 '22 17:09

sharkySharks