A small companion library for node-postgres that reduces boilerplate by using tagged template literals for SQL queries, with automatic result row/column unwrapping. Current stable version 3.0.0, released periodically. Key differentiators: Promise-based API, runtime SQL injection prevention via tagged templates, built-in transaction and savepoint handling with retry on serialization failures/deadlocks, first-class TypeScript support, and not a framework – works directly with pg.Pool/pg.PoolClient.
npm install possuNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows a basic query selecting one row by id using tagged template literal and automatic unwrapping.
Use import syntax and set type: 'module' in package.json, or use dynamic import().
Use sql`SELECT * FROM users` instead of sql('SELECT * FROM users')Prefer sql`SELECT name FROM users` and let possu unwrap automatically.
Use for (const row of result) instead of for await (const row of result).
Always combine nested sql calls as arguments to parent sql tag – not concatenated strings.
Use sql`...` syntax or import { sql } from 'possu'.Call query(poolClient, sql`...`) – possu expects a client/pool as first argument, not the pool's method.
Install with npm install possu, and use import syntax. For older Node, use dynamic import or downgrade to v2.
Wrap your SQL string with sql`...`.