-
Type: New Feature
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Aggregation Framework
-
None
-
(copied to CRM)
Example function:
db.coll.insert({id: 'foo', a: 100, b: 200, c: 300, d: {e: 400, f:500}}) db.coll.aggregate([ {$docUnwind: {id: 0}}, // syntax similar to $project for whitelisting or blacklisting which fields to unwind ]) {id: 'foo', f_name: 'a', f_value: 100} {id: 'foo', f_name: 'b', f_value: 200} {id: 'foo', f_name: 'c', f_value: 300} {id: 'foo', f_name: 'd.e', f_value: 400} {id: 'foo', f_name: 'd.f', f_value: 500}
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.
- duplicates
-
SERVER-11392 $unwind on subdocuments
- Closed