Welcome to the new MongoDB Feedback Portal!
{Improvement: "Your idea"}
We’ve upgraded our system to better capture and act on your feedback.
Your feedback is meaningful and helps us build better products.
We’ve upgraded our feedback system to better capture, track, and act on your feedback. Here’s what you need to know:
|
What problem are you trying to solve? Focus on the what and why of the need you have, not the how you'd like it solved. |
The $unwind stage overwrites the specified array path with a non-array value. This maps poorly with statically-typed programming languages. Additionally, this causes the $unwind stage to behave poorly with nested fields (e.g. foo.0.bar). |
|
What would you like to see happen? Describe the desired outcome or enhancement. |
The $unwind stage would get an optional parameter 'as'. If not specified, the behavior is unchanged. If specified, the unwound field is written into the field specified in 'as' and the initial array is untouched. Syntax: { The $lookup and $graphLookup stages already have a 'as' output field. |
|
Why is this important to you or your team? Explain how the request adds value or solves a business need. |
In statically-typed languages, the omission of this feature is making the $unwind stage harder to use and harder to read than necessary. |
What steps, if any, are you taking today to manage this problem? |
Using a prior $set stage to write the complex path into a temporary variable, then performing the $unwind on that temporary variable, then using $set to write it back to whatever destination is intended, then $unset to remove the temporary field. Three boilerplate stages! |
Hi,
About 'the initial array is untouched': in case of 'as' parameter usage, I expect the initial array field to be removed from the result. From my pov, it makes no sense to unwind 'to an other field' and keep initial field untouched. It could cause some performance troubles.
Do we agree?