Listing all the documents of a MongoDB database

In this short post, we are going to learn how to list all columns of every table in a MongoDB database.
We want to get all documents in a database.


We connect to our MongoDB instance, and enter the database we want to explore.
We will use a different way depending on the return we expect. If we want JSON, we will use “db.getCollectionNames()“, if we want a simple shell output, “show collections” will do the trick.

Return JSON

USE local

Return text

USE local
show collections

Dont’ forget to change “local” in the examples and use the name of the database you want to check.

Leave a Reply

Your email address will not be published.