{"id":43558,"library":"pg-helpers","title":"pg-helpers","description":"pg-helpers is a lightweight Node.js library (v1.0.0) providing utility functions for querying PostgreSQL databases. It wraps common query patterns such as select, insert, update, and delete, and offers simple connection management via a configuration object. The library is designed for small-to-medium projects that want a thin layer over raw SQL without a full ORM. It uses the 'pg' package as a peer dependency and is released infrequently. Compared to Knex or Prisma, it provides minimal abstraction and is best for developers who prefer writing SQL with some helper shortcuts.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/postgres-plugin/pg-helpers","tags":["javascript","Postgres"],"install":[{"cmd":"npm install pg-helpers","lang":"bash","label":"npm"},{"cmd":"yarn add pg-helpers","lang":"bash","label":"yarn"},{"cmd":"pnpm add pg-helpers","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for PostgreSQL client connectivity","package":"pg","optional":false}],"imports":[{"note":"Package is ESM-only; CJS require cannot be used directly.","wrong":"const query = require('pg-helpers').query","symbol":"query","correct":"import { query } from 'pg-helpers'"},{"note":"Named export, not default. Use destructuring.","wrong":"import select from 'pg-helpers'","symbol":"select","correct":"import { select } from 'pg-helpers'"},{"note":"Namespace import to access all helpers at once. Avoid mixing with named imports.","symbol":"pgHelpers","correct":"import * as pgHelpers from 'pg-helpers'"}],"quickstart":{"code":"import { query, select, insert, update, del } from 'pg-helpers';\nimport pg from 'pg';\n\nconst pool = new pg.Pool({\n  user: process.env.PG_USER || 'postgres',\n  database: process.env.PG_DATABASE || 'test',\n  password: process.env.PG_PASSWORD || '',\n  host: 'localhost',\n  port: 5432,\n});\n\nasync function main() {\n  await query(pool, 'CREATE TABLE IF NOT EXISTS users (id SERIAL PRIMARY KEY, name TEXT)');\n  await insert(pool, 'users', { name: 'Alice' });\n  const users = await select(pool, 'users', { name: 'Alice' });\n  console.log(users.rows);\n}\n\nmain().catch(console.error);","lang":"typescript","description":"Shows how to set up a pg pool and use query, select, and insert helpers."},"warnings":[{"fix":"Use import syntax or set { \"type\": \"module\" } in package.json.","message":"Package is ESM-only. It will not work with require() in CommonJS projects.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Use it as del() or alias it with a different name when importing.","message":"The 'del' function conflicts with JavaScript's delete operator; may cause confusion.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Run 'npm install pg' in your project.","message":"The 'pg' package must be installed separately as a peer dependency; not bundled.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'abstract':84 'best':87 'common':22 'compar':76 'configur':39 'connect':35 'databas':19 'delet':31 'depend':71 'design':44 'develop':89 'full':61 'function':15 'helper':3,6,96 'infrequ':75 'insert':28 'javascript':98 'knex':78 'layer':55 'librari':11,42 'lightweight':9 'manag':36 'medium':49 'minim':83 'node.js':10 'object':40 'offer':33 'orm':62 'packag':67 'pattern':24 'peer':70 'pg':2,5,66 'pg-helper':1,4 'postgr':99 'postgresql':18 'prefer':91 'prisma':80 'project':50 'provid':13,82 'queri':17,23 'raw':57 'releas':74 'select':27 'shortcut':97 'simpl':34 'small':47 'small-to-medium':46 'sql':58,93 'thin':54 'updat':29 'use':64 'util':14 'v1.0.0':12 'via':37 'want':52 'without':59 'wrap':21 'write':92","created_at":"2026-06-05T17:00:22.494509+00:00","updated_at":"2026-06-05T17:00:22.494509+00:00","problems":[{"fix":"Run 'npm install pg-helpers pg'","cause":"Package not installed or not resolvable","error":"Error: Cannot find module 'pg-helpers'"},{"fix":"Use ES module import syntax: import { query } from 'pg-helpers'","cause":"CommonJS require incorrectly used for ESM package","error":"TypeError: (0 , _pgHelpers.query) is not a function"}],"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/postgres-plugin/pg-helpers#readme","github":"https://github.com/postgres-plugin/pg-helpers","docs":null,"changelog":null,"pypi":null,"npm":"pg-helpers","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}}