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

Investigate changes in SERVER-37690: countDocuments throws an error when matching 0 document

      Description

      Downstream Change Summary

      The shell's countDocuments method had thrown an uninformative error if the collection is empty or does not exist. Now it will return 0, the same as drivers do.

      Description of Linked Ticket

      `countDocuments` throws an error when matching 0 document.

      I would have expected it to follow what `count` does, which is return 0.

      With both versions `4.0.3` and `4.1.4` (haven't checked intermediary ones), the error I get from the bellow `steps to reproduce` is:

      2018-10-20T16:26:44.252+0100 E QUERY [js] TypeError: res[0] is undefined :
       DBCollection.prototype.countDocuments@src/mongo/shell/collection.js:1418:5
       @(shell):1:1
       

      Scope of changes

      Impact to Other Docs

      MVP (Work and Date)

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

            Assignee:
            jeffrey.allen@mongodb.com Jeffrey Allen
            Reporter:
            backlog-server-pm Backlog - Core Eng Program Management Team
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              4 years, 28 weeks ago