express-database
Usage
const mysql = const app = // define here routes without needed database connection// ex: static routes, index page, etw. // use the database middlewareapp
API
req.database
req.database
- reference to connection to your database.req.database.connect
- reference to raw connection to your databasereq.database.close
- close connection to database, called automatically.
options
options.db
- connection's constructor; it should have methodopen
that returnPromise
with connection.
Connectors
Each connector should have connect
property and method close()
. Is's required api. Connectors can have any count of other helper methods. Each method should return Promise
. Property connect
should hold reference to raw api. See express-database-mysql
as example.
License
MIT, 2016 (c) Dmitry Tsvettsikh