import { setupRecordConnectErrors } from "./postgres/record-connect-error";
import { PostgreSQL } from "./postgres/types";
const base = require("./postgres-base");
export const {
pg_type,
expire_time,
one_result,
all_results,
count_result,
PROJECT_COLUMNS,
PUBLIC_PROJECT_COLUMNS,
} = base;
let theDB: PostgreSQL | undefined = undefined;
export function db(opts = {}): PostgreSQL {
if (theDB === undefined) {
let PostgreSQL = base.PostgreSQL;
for (const module of [
"server-queries",
"blobs",
"synctable",
"user-queries",
"ops",
]) {
PostgreSQL = require(`./postgres-${module}`).extend_PostgreSQL(
PostgreSQL,
);
}
const theDBnew = new PostgreSQL(opts);
setupRecordConnectErrors(theDBnew);
theDB = theDBnew;
}
if (theDB == null) {
throw new Error("Fatal error setting up PostgreSQL instance");
}
return theDB;
}
import getPool from "./pool";
export { stripNullFields } from "./postgres/util";
export { getPool };