@heyhru/server-plugin-pg
v0.3.0
Published
PostgreSQL connection pool with unified execute interface
Readme
@heyhru/server-util-pg
PostgreSQL connection pool with unified DbPool interface.
Install
pnpm add @heyhru/server-util-pgAPI
createPool(config): DbPool
Create a PostgreSQL connection pool.
import { createPool } from "@heyhru/server-util-pg";
const pool = createPool({
host: "localhost",
port: 5432,
database: "mydb",
username: "postgres",
password: "password",
poolMin: 2,
poolMax: 10,
});
const rows = await pool.execute("SELECT * FROM users");
await pool.end();DbPool interface
interface DbPool {
execute(sql: string): Promise<unknown[]>;
end(): Promise<void>;
}