[SERVER-5916] In $group allow "$$ROOT" to expand to the whole document matched. Created: 23/May/12 Updated: 11/Jul/16 Resolved: 24/Sep/13 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Aggregation Framework |
| Affects Version/s: | 2.1.1 |
| Fix Version/s: | 2.5.3 |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Clifford Hammerschmidt | Assignee: | Mathias Stearn |
| Resolution: | Done | Votes: | 5 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||
| Participants: | |||||||||
| Description |
|
Allow: Currently {$push:"$field"} is supported, which accumulates a field from the document. Adding support for "$$ROOT" to expand to the full document would seem to make sense then. |
| Comments |
| Comment by auto [ 24/Sep/13 ] |
|
Author: {u'username': u'RedBeard0531', u'name': u'Mathias Stearn', u'email': u'mathias@10gen.com'}Message: This represents the whole variable (usually the full incoming document). |
| Comment by Mathias Stearn [ 17/Sep/13 ] |
|
This should be handled by the $$ROOT variable introduced in |
| Comment by Clifford Hammerschmidt [ 18/Dec/12 ] |
|
I'm hoping this is a quick and easy one. The main use would be for partitioning data into N sets. Support in $project may make more sense since then you can do: db.x.aggregate( } } This would allow for grouping data in a collection based on a computation of the data without having to specify all the fields in both the $project and the $group statements. It also feel more inline with the idea of "schemaless" data as it doesn't force the documents processed to have anything other than the fields used in the computation present and makes the aggregation query more reusable in general. |