-
Type: New Feature
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Aggregation Framework
-
None
-
Query
If I'm grouping by something, unless I explicitly specify an accumulator for every field, that field will be lost. The only work around that exists right now is to re-query for the document by its _id and fill in the fields.
There should be some way to specify a $default accumulator that's performed on any unspecified field. For example:
{ $group: { _id: '$_id', number:
{ $sum: 'number'}, $default: {"defaulted$property": {$first:$property}}} }
The above would group by _id, accumulate the number property as a sum, and for every other property it would simply add in the first value in that group for that property as the name "defaulted"+propertyName
- related to
-
SERVER-5781 Implement $addFields aggregation stage for using expression language to add new fields to a document
- Closed