Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-14249

Investigate changes in SERVER-54236: Implement $count accumulator

      Description

      Downstream Change Summary

      This ticket adds $count as an accumulator to the $group stage:

      { $count: {} }
      

      is desugared to:

      { $sum: 1 }
      

      Description of Linked Ticket

      This task is for adding support for $count as an accumulator to the $group stage.

      Scope of changes

      New accumulator: https://docs.mongodb.com/manual/reference/operator/aggregation/#accumulators-group

      Make sure we update https://docs.mongodb.com/manual/reference/operator/aggregation/group/#count-the-number-of-documents-in-a-collection as part of this change.

      Also:

      https://docs.mongodb.com/manual/reference/operator/aggregation/count/

      Behavior section, current:

      db.collection.aggregate( [
         { $group: { _id: null, myCount: { $sum: 1 } } },
         { $project: { _id: 0 } }
      ] )
      

      Desired:

      db.collection.aggregate( [
         { $group: { _id: null, myCount: { $count: {} } } },
         { $project: { _id: 0 } }
      ] )
      

      Impact to Other Docs

      MVP (Work and Date)

      Resources (Scope or Design Docs, Invision, etc.)

            Assignee:
            joseph.dougherty@mongodb.com Joseph Dougherty
            Reporter:
            backlog-server-pm Backlog - Core Eng Program Management Team
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              3 years, 5 weeks, 1 day ago