Consider support for field renaming in $unwind stage

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Unresolved
    • Priority: Trivial - P5
    • None
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • None
    • Query Optimization
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      In my experience, array fields in documents are usually labeled as plural (e.g. items: ['item']). This becomes a little confusing to read once they are past the $unwind stage because the value will become singular but the field name remains plural.  This can be alleviated via an $addFields stage directly after the $unwind, but that seems inefficient.

       

      A potential solution here could be to add an 'as' option to the $unwind stage like the following:

       

      { $unwind: { path: '$items', as: 'item' } }

       

      This would $unwind and rename the unwound field to the specified name in a single stage, and it is consistent with the naming conventions of expressions like $filter.

       

              Assignee:
              [DO NOT USE] Backlog - Query Optimization
              Reporter:
              Jeffrey Mariconda
              Votes:
              1 Vote for this issue
              Watchers:
              7 Start watching this issue

                Created:
                Updated: