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.
USE local db.getCollectionNames()
USE local show collections
Dont’ forget to change “local” in the examples and use the name of the database you want to check.