$group all fields
$group should have the ability to allow specifying all fields in a document (without explicitly defining them all, which can lead to duplicating dozens of lines just to do "key: $first")
This will help users that use $unwind and then want to $group the results without having to do a subsequent $lookup and $mergeObjects (or similar) to get the final document structure they're looking for.
1
vote
![](https://secure.gravatar.com/avatar/a9ea25ace811bb1e0db639589fe4fae6?size=40&default=https%3A%2F%2Fassets.uvcdn.com%2Fpkg%2Fadmin%2Ficons%2Fuser_70-6bcf9e08938533adb9bac95c3e487cb2a6d4a32f890ca6fdc82e3072e0ea0368.png)
-
Would using $$ROOT like this work:
{$group: {_id: '$groupkey', document: {$first: '$$ROOT'}}} ?If not, could you provide an example of the document and the pipeline that achieves the transformation (with the stages you mentioned). thank you