Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

connect() is asynchronous, API (esp. isConnected()) encourages synchronous interface #18

@fatuhoku

Description

@fatuhoku

Node-DBI users are encouraged to write code like the following (in Coffeescript):

db = new DBWrapper 'sqlite3', { ... }
db.connect()
console.error 'Failed to connect to database' if not db.isConnected()

The two solutions to this issue are:

  • use async, and document this in README.md:
db = new DBWrapper 'sqlite3', { ... }
async.series [
   -> db.connect()
   -> console.error 'Failed to connect to database' if not db.isConnected()
]
  • provide a callback in the connect(): i.e. change the interface to connect(callback)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions