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

countDocuments should use group with _id: 1

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.2.0
    • Component/s: None
    • Labels:
      None

      Description

      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.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: