countDocuments throws error when query matches zero docs

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Critical - P2
    • 3.1.1
    • Affects Version/s: 3.1.0
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      This line:

      https://github.com/mongodb/node-mongodb-native/blob/3.1/lib/operations/collection_ops.js#L237

      will throw an error if the query to countDocuments does not match:

      db.collection('somecollection').countDocuments({foo: 'blah'})
      

      Uncaught TypeError: Cannot read property 'n' of undefined

      `docs` is an empty array if the query does not match.
       

              Assignee:
              Rebecca Weinberger (Inactive)
              Reporter:
              Alex Stanciu
              None
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: