TypeScript wrapper around node-postgres offering a typed SQL template tag and transaction helpers. Current version: 2.5.1. Provides both Promise-based and fp-ts Task-based query methods. Integrates tightly with TypeScript to ensure type safety in SQL queries and result sets. Differentiates from raw node-postgres by reducing boilerplate and offering a first-class TypeScript experience.
npm install pg-tsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Initialize a connection pool, execute a typed query returning a single row, and handle errors.
Use import type { Pool } from 'pg-ts' or import it only for type annotations.Always prefix template literal with SQL (e.g., SQL`SELECT * FROM table WHERE id = ${id}`).Call getPool(config) as a normal function, not as a constructor.
Replace 'const { getPool } = require("pg-ts")' with 'const getPool = require("pg-ts").default' or use ES import.Install fp-ts: 'npm install fp-ts' or 'yarn add fp-ts' if using Task methods.
Call getPool() (e.g., 'const pool = getPool(config)') before using pool methods.