How to list all documents in MongoDB collection


MongoDB can be used locally or hosted on cloud , in any case MongoDB Compass is a great tool for managing collections.

Compass come with a console, which you can use manipulate docs. Let’s learn how to explore documents

List all document

we can list collection using the following on terminal/ Compass console

use myDB
db.users.find() 

Here use myDB is is used to change the database and access the collection using db.< collection>.find() to list all json documents inside it.

You may also love to read following tutorials

Published by

Manoj

A developer,teacher and a blogger obsessed with Python,Dart and open source world from India

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.