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

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

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Aggregation Framework
    • Query Optimization

    Description

      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)

      Attachments

        Activity

          People

            backlog-query-optimization Backlog - Query Optimization
            asya.kamsky@mongodb.com Asya Kamsky
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated: