1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-11-01 19:07:38 +01:00
unleash.unleash/src/lib/db/db-pool.ts

28 lines
654 B
TypeScript
Raw Normal View History

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({
2014-11-14 15:06:53 +01:00
client: 'pg',
version: db.version,
connection: db,
pool: db.pool,
searchPath: db.schema,
asyncStackTraces: true,
log: {
debug: (msg) => logger.debug(msg),
warn: (msg) => logger.warn(msg),
error: (msg) => logger.error(msg),
},
2014-11-14 15:06:53 +01:00
});
}
// for backward compatibility
module.exports = {
createDb,
};