Simple functional helper layer on top of node-postgres (pg) providing convenient methods like `one()`, `many()`, `none()`, `withTransaction()`, and `canConnect()` on both Pool and Client instances. Version 3.0.2 requires Node >= 10 and peer dependency pg ^8.0.0. The library extends pg.Pool and pg.Client with ES6 classes (no longer mutating originals, stores originals as pg._Pool and pg._Client). Supports tagged template literal `sql` for safe parameterized queries. Offers both manual pool initialization and singleton mode. Release cadence appears low; no recent updates.
npm install pg-lazyNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Initializes a pg-lazy Pool with a connection string, then uses `one()` to fetch a single row.
Use the returned Pool/Client from pgLazy() instead of pg.Pool directly.
Replace pool.isConnected() or client.isConnected() with pool.canConnect() or client.canConnect().
Update code to use the returned Pool/Client instead of pg.Pool/pg.Client.
Either pass {singleton:true} or manually create a new Pool() instance.Ensure Node >= 10.
npm install pg-lazy pg
Use const { Pool } = pgLazy(pg, config); const pool = new Pool();Always use sql`...` for parameterized queries (e.g., pool.one(sql`SELECT * FROM t WHERE id = ${id}`)).