4 / 4
Mar 12

Hello, I want to extract all the fields present in a collection, including nested fields. How can I extract the fields using shell or compass?

Hello Jack,

I want to list out only field names present in a collection. values are not required.

Object.keys(db.YOURCOLLECTION.findOne()) gets the top level.
You’d need to write something recursive like that to get the sub fields.