import { drizzle } from "drizzle-orm/node-postgres";
import pg from "pg";
import * as schema from "./schema";
let pool:pg.Pool|undefined;
export function getPool(){if(!pool)pool=new pg.Pool(process.env.DATABASE_URL?{connectionString:process.env.DATABASE_URL,max:5}:{host:process.env.PGHOST||"127.0.0.1",port:Number(process.env.PGPORT||5432),database:process.env.PGDATABASE,user:process.env.PGUSER,password:process.env.PGPASSWORD,max:5});return pool}
export function getDb(){return drizzle(getPool(),{schema})}
