@tricoteuses/senat
Version:
Handle French Sénat's open data
27 lines (26 loc) • 702 B
JavaScript
import { Kysely, PostgresDialect } from "kysely";
import * as pg from "pg";
import { types } from "pg";
import Cursor from "pg-cursor";
import config from "./config";
// Map int8 to number instead of string
// https://github.com/brianc/node-pg-types#use
pg.types.setTypeParser(types.builtins.INT8, (val) => {
return parseInt(val, 10);
});
const senatPool = new pg.Pool({
database: "senat",
host: config.db.host,
user: config.db.user,
password: config.db.password,
port: config.db.port,
max: 10,
});
const senatDialect = new PostgresDialect({
pool: senatPool,
cursor: Cursor,
});
export const dbSenat = new Kysely({
log: ["error"],
dialect: senatDialect,
});