[SERVER-38454] Consider support for field renaming in $unwind stage Created: 07/Dec/18 Updated: 06/Dec/22 |
|
| Status: | Backlog |
| Project: | Core Server |
| Component/s: | Aggregation Framework |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Trivial - P5 |
| Reporter: | Jeffrey Mariconda | Assignee: | Backlog - Query Optimization |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Assigned Teams: |
Query Optimization
|
| Participants: |
| Description |
|
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:
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.
|