UNPKG

sequelize-pg-utilities

Version:

An opinionated set of database utilities that manage creating and connecting to a Postgres database

26 lines (22 loc) 532 B
const NAMES = [ ['DB_POOL_ACQUIRE', 'acquire'], ['DB_POOL_EVICT', 'evict'] ] const appendOptionalPoolOptions = (config, also = {}) => { const append = (acc, [e, n]) => process.env[e] || config.pool[n] ? { ...acc, [n]: Number(process.env[e] || config.pool[n]) } : acc return pool => config.pool ? { ...pool, ...also, ...NAMES.reduce(append, config.pool) } : { ...pool, ...also } } module.exports = appendOptionalPoolOptions