I would like to retrieve the names of all the nested keys present in all the documents in a given mongodb collection.
E.g.:
> db.sample.insert({account: 'abc', account_type: 'individual', properties:
{title: 'mr', gender: 'M', dob: '19850101' }});
> db.sample.insert({account: 'xyz', account_type: 'individual', properties:
{title: 'ms', gender: 'F' }});
> db.sample.insert({account:'lmn', account_type: 'business', properties:
{title: 'messrs', industry: 'telecom', estd_on: '19850301' }});
I would like to get the unique keys (including all the nested keys) like:
[account, account_type, properties.title, properties.gender, properties.dob, properties.industry, properties.estd_on]