Added connection method to database info lib

- this allows you to pass in a different DB instance than the one that
  the library is initialized with
This commit is contained in:
Daniel Lockyer 2022-03-01 16:05:27 +01:00
parent bb04fc49da
commit d8d77ed0ba

View File

@ -95,4 +95,15 @@ module.exports = class DatabaseInfo {
isMySQL() {
return ['mysql', 'mysql2'].includes(this._driver);
}
/**
* This allows you to use a different DB connection than the one we initialized the lib with
*
* @param {import('knex')} knex
*
* @returns DatabaseInfo
*/
connection(knex) {
return new DatabaseInfo(knex);
}
};