DEV Community

Cover image for Find all columns of a collection in MongoDB
Visakh Vijayan
Visakh Vijayan

Posted on • Edited on

Find all columns of a collection in MongoDB

Since collections are not structured i.e. all documents don't follow the same structure, it becomes hard to find out the exhaustive list of keys in a document.

Even though there are answers on Stackoverflow where they have solved it using MapReduce in MongoDB, the easiest way I found was to use the "Analyze Schema" option of MongoDB Compass. It gives an overview of all the keys and data variations in a nice UI.

Alt Text

Comment below if you have an easier way to do this.

Happy programming!

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more