I'm doing a $group within my aggregation pipeline, where I $push one property to an array, and for all the remaining properties I simply take the $first:
{ $group: { '_id': '$_id', property1: { $push: '$property1' }, property2: { $first: '$property2' }, property3: { $first: '$property3' }, property4: { $first: '$property4' }, property5: { $first: '$property5' }, property6: { $first: '$property6' }, property7: { $first: '$property7' }, // … }}, Is there a possibility to specify this in a more concise way? I am hoping for something like the following (which is not working), to say “use $push for property1, and $first for anything else”:
{ $group: { '_id': '$_id', property1: { $push: '$property1' }, '*': { $first: '$*' } }},
$firstaccumulator in$groupstage.$replaceRootand$mergeObjects. I'll post details later on.$groupstage is the blocking stage in mongodb avoid as much as you can