{"id":43562,"library":"pg-lazy","title":"pg-lazy","description":"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.","status":"active","version":"3.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/uniibu/pg-Lazy","tags":["javascript","node-pg","pg","postgres","helpers","one","many","none","async"],"install":[{"cmd":"npm install pg-lazy","lang":"bash","label":"npm"},{"cmd":"yarn add pg-lazy","lang":"bash","label":"yarn"},{"cmd":"pnpm add pg-lazy","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency – requires node-postgres ^8.0.0","package":"pg","optional":false}],"imports":[{"note":"Default export via ESM; CJS uses require('pg-lazy') directly.","wrong":"const pgLazy = require('pg-lazy').default","symbol":"pgLazy","correct":"import pgLazy from 'pg-lazy'"},{"note":"Pool is not exported at top-level; it's destructured from the object returned by pgLazy().","symbol":"Pool","correct":"const { Pool } = pgLazy(require('pg'), { connectionString })"},{"note":"sql tag is only available from the return object of the default export.","wrong":"import { sql } from 'pg-lazy'","symbol":"sql","correct":"import pgLazy from 'pg-lazy';\nconst { sql } = pgLazy(pg, config);"}],"quickstart":{"code":"import pg from 'pg';\nimport pgLazy from 'pg-lazy';\n\nconst config = { connectionString: process.env.DATABASE_URL ?? 'postgres://localhost:5432/mydb' };\nconst { Pool, sql } = pgLazy(pg, config);\n\nconst pool = new Pool();\n\nasync function getUser(id: number) {\n  const user = await pool.one(sql`SELECT * FROM users WHERE id = ${id}`);\n  return user;\n}\n\ngetUser(1).then(console.log).catch(console.error);","lang":"typescript","description":"Initializes a pg-lazy Pool with a connection string, then uses `one()` to fetch a single row."},"warnings":[{"fix":"Use the returned Pool/Client from pgLazy() instead of pg.Pool directly.","message":"Pool and Client are no longer instances of pg.Pool and pg.Client in v3 – they are custom exports.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Replace pool.isConnected() or client.isConnected() with pool.canConnect() or client.canConnect().","message":"isConnected() renamed to canConnect() in v3.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Update code to use the returned Pool/Client instead of pg.Pool/pg.Client.","message":"v2+ no longer mutates pg.Pool and pg.Client; stores originals as pg._Pool and pg._Client.","severity":"breaking","affected_versions":">=2.0.0 <3.0.0"},{"fix":"Either pass {singleton:true} or manually create a new Pool() instance.","message":"Singleton pool initialization requires passing a third argument {singleton:true}.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Ensure Node >= 10.","message":"Node 8 support dropped in v2; v3 requires Node >= 10.","severity":"deprecated","affected_versions":">=3.0.0"}],"env_vars":null,"search_vec":"'10':35 '3.0.2':32 '8.0.0':40 'appear':79 'async':94 'cadenc':78 'canconnect':24 'class':49 'client':29 'conveni':16 'depend':38 'es6':48 'extend':43 'function':5 'helper':6,90 'initi':73 'instanc':30 'javascript':84 'layer':7 'lazi':3 'librari':42 'like':18 'liter':63 'longer':51 'low':80 'mani':20,92 'manual':71 'method':17 'mode':76 'mutat':52 'node':12,34,86 'node-pg':85 'node-postgr':11 'none':21,93 'offer':69 'one':19,91 'origin':53,55 'parameter':67 'peer':37 'pg':2,14,39,87,88 'pg-lazi':1 'pg._client':59 'pg._pool':57 'pg.client':46 'pg.pool':44 'pool':27,72 'postgr':13,89 'provid':15 'queri':68 'recent':82 'releas':77 'requir':33 'safe':66 'simpl':4 'singleton':75 'sql':64 'store':54 'support':60 'tag':61 'templat':62 'top':9 'updat':83 'version':31 'withtransact':22","created_at":"2026-06-05T17:00:23.758600+00:00","updated_at":"2026-06-05T17:00:23.758600+00:00","problems":[{"fix":"npm install pg-lazy pg","cause":"Missing install of pg-lazy or its peer dependency pg.","error":"Cannot find module 'pg-lazy'"},{"fix":"Use const { Pool } = pgLazy(pg, config); const pool = new Pool();","cause":"Using a regular pg.Pool instead of the returned Pool from pgLazy().","error":"TypeError: pool.one is not a function"},{"fix":"Always use sql`...` for parameterized queries (e.g., pool.one(sql`SELECT * FROM t WHERE id = ${id}`)).","cause":"Calling pool.query(sql`...`) without the sql tag, or using plain string in pool.one().","error":"Error: parameter 'text' must be a string"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/uniibu/pg-Lazy#readme","github":"https://github.com/uniibu/pg-Lazy","docs":null,"changelog":null,"pypi":null,"npm":"pg-lazy","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}