knex-mysql-middleware
Version:
Set a MySQL flavored Knex connection that can be accessed via Koa or Express middleware.
33 lines (24 loc) • 394 B
JavaScript
;
/**
* Imports.
*/
var debug = require('debug')('knex-mysql-middleware');
/**
* Exports.
*/
module.exports = close;
/**
* Close database connection(s).
*
* @param {Object} knex
* Knex database connection object.
*/
function close(knex) {
knex && knex.destroy && knex.destroy(log);
}
/**
* Debug logging.
*/
function log() {
debug('DB connection closed.');
}