Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-27835

add aggregation stage $countBy which is equivalent to group with sum

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • Query Optimization

      It would be nice to have syntactic sugar for the following stage which I type all the time:

      {$group:{_id:"$field", count:{$sum:1}}}
      

      Something like {$countBy:"$field"} would be more readable and be analogous to $count and $sortByCount stages (and would use same field names as sortByCount - i.e. count field for sum)

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            asya.kamsky@mongodb.com Asya Kamsky
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: