mirror of
https://github.com/Unleash/unleash.git
synced 2024-11-01 19:07:38 +01:00
7ddbff2669
* implemented changes to resolve issue 1170 * added applicationName to the list of db options in the documentation' Co-authored-by: Daniele Casal <daniele.casal@lloydsbanking.com> Co-authored-by: Sukhvinder Panesar <79143027+esspee-lbg@users.noreply.github.com>
31 lines
732 B
TypeScript
31 lines
732 B
TypeScript
import { knex, Knex } from 'knex';
|
|
import { IUnleashConfig } from '../types/option';
|
|
|
|
export function createDb({
|
|
db,
|
|
getLogger,
|
|
}: Pick<IUnleashConfig, 'db' | 'getLogger'>): Knex {
|
|
const logger = getLogger('db-pool.js');
|
|
return knex({
|
|
client: 'pg',
|
|
version: db.version,
|
|
connection: {
|
|
...db,
|
|
application_name: db.applicationName,
|
|
},
|
|
pool: db.pool,
|
|
searchPath: db.schema,
|
|
asyncStackTraces: true,
|
|
log: {
|
|
debug: (msg) => logger.debug(msg),
|
|
warn: (msg) => logger.warn(msg),
|
|
error: (msg) => logger.error(msg),
|
|
},
|
|
});
|
|
}
|
|
|
|
// for backward compatibility
|
|
module.exports = {
|
|
createDb,
|
|
};
|