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

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Won't Fix
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Docs
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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.)

            Assignee:
            Unassigned
            Reporter:
            Thomas Boutell
            None
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: