DEV Community

loading...
Cover image for Find all columns of a collection in MongoDB

Find all columns of a collection in MongoDB

Visakh Vijayan
Willing to learn anything and everything exciting. Always awake. Skips food for fun.
Updated on ・1 min read

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!

Discussion (0)

Forem Open with the Forem app