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

Documentation for Db.collection method in Node.js driver has incorrect promises example

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Docs

    Description

      Description

      The example provided here for working with promises is incorrect:

      http://mongodb.github.io/node-mongodb-native/2.2/api/Db.html#collection

      db.createCollection('test_correctly_access_collections_with_promise').then(function(err, result) { ... }
      

      The "then" function does not receive an error. It just receives "result". Any error would be caught by a catch() function, which should also be shown.

      In addition, this example contains several API calls, but only this one line that attempts to use promises, and the rest is a "pyramid of doom" using callbacks. The example should use promises and chain with then() throughout, with a final catch().

      Scope of changes

      Impact to Other Docs

      MVP (Work and Date)

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

      Attachments

        Activity

          People

            Unassigned Unassigned
            boutell Thomas Boutell
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: