$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
Chris
shared this idea
-
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