pg-chain is a chainable SQL query builder for PostgreSQL in Node.js, using tagged template literals to construct SQL statements. Version 1.1.3 is the current stable release, with no frequent update cadence documented. It provides methods like SELECT, INSERT_INTO, UPDATE, DELETE_FROM, WITH_RECURSIVE, etc., that return chainable objects. Differentiators include no external dependencies, TypeScript type definitions included, and support for both .toSql() output and direct use with the pg library via .text and .values properties. It is designed for simplicity and composability, allowing reusable conditionals for pagination.
npm install pg-chainNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic SELECT, INSERT, UPDATE, and DELETE queries using pg-chain's tagged template syntax.
Use EXISTS(SELECT...) instead of EXISTS`SELECT...`.
Import { INSERT_INTO } from 'pg-chain' instead of { INSERT }.Import { DELETE_FROM } from 'pg-chain' instead of { DELETE }.Use WITH_RECURSIVE for recursive CTEs; for non-recursive CTEs, use WITH_RECURSIVE without RECURSIVE in SQL? Actually, WITH_RECURSIVE always adds RECURSIVE. To get a plain WITH, you must manually construct or use a workaround.
Run `npm install pg-chain` and use ESM import: `import { SELECT } from 'pg-chain'`.Use `import { INSERT_INTO } from 'pg-chain'`.Use `import { DELETE_FROM } from 'pg-chain'`.Ensure the method supports chaining; for example, AS and EXISTS return different objects, not chainable methods.
No dependency data recorded yet.