Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-1888

countDocuments should use group with _id: 1

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.2.0
    • Affects Version/s: None
    • Component/s: None
    • None

      We currently use

      {'$group': {'_id': null, 'n': {'$sum': 1} } }
      

      as an aggregation stage for the countDocuments. The _id can be any constant value, like 1 or 0. Since it can be any constant value, we should change the group stage to:

      {'$group': {'_id': 1, 'n': {'$sum': 1} } }
      

      This helps us with test runners and languages that consider null to be an indication that a key is not present.

            Assignee:
            daniel.aprahamian@mongodb.com Daniel Aprahamian (Inactive)
            Reporter:
            daniel.aprahamian@mongodb.com Daniel Aprahamian (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: