cloudant / nodejs-cloudant

Cloudant Node.js client library
Apache License 2.0
255 stars 90 forks source link

Getting a PassThroughDuplex object when using promises plugin and getting all docs #321

Closed ScottChapman closed 6 years ago

ScottChapman commented 6 years ago

Current version of Node, and module.

async function main(params) {
    if (!db) {
      cloudant = Cloudant({url: myURL, plugin: "promises"});
      db = cloudant.use(dbName);
      console.log("Connected");
      var list = await db.list({include_docs:true}) // was expecting to be a promise...
      console.log("Documents")
      console.dir(list);
    }
}
ricellis commented 6 years ago

In 2.x versions the the option is called plugins not plugin from the change to support multiple plugins. As described in the migration guide you need to update your code to:

Cloudant({url: myURL, plugins: "promises"});
ScottChapman commented 6 years ago

Works!