api-v1/db/queryHelper/knex.js

33 lines
774 B
JavaScript

import knex from 'knex';
import 'dotenv/config';
/**
* Knex.js configuration for query helper
*
* Uses the same database connection settings as pool.js
* but creates a separate Knex instance for the query builder.
*
* Note: This is separate from db/pool.js which uses the native pg Pool.
* Both can coexist - pool.js for existing raw SQL queries,
* and this for the new JSON-based query helper.
*/
const config = {
client: 'pg',
connection: {
host: process.env.PGHOST || '127.0.0.1',
port: Number(process.env.PGPORT || 5432),
user: process.env.PGUSER || 'postgres',
password: process.env.PGPASSWORD || 'postgres',
database: process.env.PGDATABASE || 'postgres',
},
pool: {
min: 2,
max: 10,
},
};
const db = knex(config);
export default db;