1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00
unleash.unleash/lib/db/db-pool.js
Mathias Åhsberg 144e832cdc
feat: Add support for explicitly set database version. (#654)
Co-authored-by: Mathias Åhsberg <mathias.ahsberg@resurs.se>
2020-11-20 11:37:56 +01:00

27 lines
598 B
JavaScript

'use strict';
const knex = require('knex');
module.exports.createDb = function({
db,
poolMin = 2,
poolMax = 20,
databaseSchema,
getLogger,
}) {
const logger = getLogger('db-pool.js');
return knex({
client: 'pg',
version: db.version,
connection: db,
pool: { min: poolMin, max: poolMax },
searchPath: databaseSchema,
log: {
debug: msg => logger.debug(msg),
info: msg => logger.info(msg),
warn: msg => logger.warn(msg),
error: msg => logger.error(msg),
},
});
};