$unwind, or a new operator, should emit new records for each key-value pair in a subdocument. A good example of where this would be useful is if a document contained a histogram (e.g. counts of unique account ids), and one wanted to use the aggregation framework to calculate the number of unique keys in that histogram (e.g. number of unique accounts, i.e. the length of the subdocument).
Additional description from
In short, it will take the fields in a document, and unwind a portion of them into name, value pairs, making a separate document for each.
One use case for this is collecting statistics across a dynamic list of fields.
And a request, also from
It is critical (for our use case) to have the type of the field (BSON id) in the output as well - e.g.
Some examples for arrays: