{"id":43449,"library":"node-pg-helper","title":"node-pg-helper","description":"A small wrapper around node-postgres providing simplified CRUD helper functions (insert, update, upsert, selectAllRows) for PostgreSQL. Version 1.0.5, released once, no active development observed on GitHub. It relies on the 'pg' Pool client, which must be configured and set via setClient(). Avoids raw SQL for basic operations but offers no query builder flexibility, migrations, or connection pooling of its own. Suitable for quick prototypes but not production-grade; alternatives like Knex, Slonik, or pg-promise are more feature-rich and maintained.","status":"maintenance","version":"1.0.5","language":"javascript","source_language":"en","source_url":"https://github.com/wherrera/node-pg-helper","tags":["javascript","nodejs","postgres"],"install":[{"cmd":"npm install node-pg-helper","lang":"bash","label":"npm"},{"cmd":"yarn add node-pg-helper","lang":"bash","label":"yarn"},{"cmd":"pnpm add node-pg-helper","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required peer dependency; node-pg-helper wraps pg's Pool for SQL queries.","package":"pg","optional":false}],"imports":[{"note":"This package is CommonJS-only (no ESM exports). Using ES import syntax will fail.","wrong":"import db from 'node-pg-helper';","symbol":"require('node-pg-helper') (default export as object)","correct":"const db = require('node-pg-helper');"},{"note":"setClient is a method on the default export object, not a named export.","wrong":"setClient(pool);","symbol":"setClient","correct":"db.setClient(pool);"},{"note":"insert only accepts table name and data object; no third argument. Extra arguments are ignored.","wrong":"await db.insert('users', { id: 100, firstname: 'john' }, {});","symbol":"insert","correct":"await db.insert('users', { id: 100, firstname: 'john' });"},{"note":"The third parameter must be a string (single conflict column), not an array.","wrong":"await db.upsert('users', { id: 100, firstname: 'john' }, ['id']);","symbol":"upsert","correct":"await db.upsert('users', { id: 100, firstname: 'john' }, 'id');"},{"note":"update does not support options like 'returning' – it only returns undefined.","wrong":"await db.update('users', { lastname: 'snow' }, { id: 100 }, { returning: true });","symbol":"update","correct":"await db.update('users', { lastname: 'snow' }, { id: 100 });"}],"quickstart":{"code":"const { Pool } = require('pg');\nconst db = require('node-pg-helper');\n\nconst pool = new Pool({\n  connectionString: process.env.DATABASE_URL ?? '',\n  ssl: { rejectUnauthorized: false }\n});\ndb.setClient(pool);\n\nasync function run() {\n  await db.insert('users', { id: 1, firstname: 'Alice', lastname: 'Smith' });\n  const rows = await db.selectAllRows('users');\n  console.log(rows);\n  await db.upsert('users', { id: 1, firstname: 'Alice', lastname: 'Jones' }, 'id');\n  await db.update('users', { lastname: 'Johnson' }, { id: 1 });\n  await db.selectAllRows('users').then(r => console.log(r));\n}\nrun().catch(console.error);","lang":"javascript","description":"Initializes a pg Pool, sets client with setClient(), performs insert, selectAllRows, upsert, and update operations."},"warnings":[{"fix":"Use pg query directly with LIMIT and OFFSET if needed.","message":"`selectAllRows` returns all rows without limit; may cause memory issues on large tables.","severity":"gotcha","affected_versions":"<=1.0.5"},{"fix":"Always call db.setClient(pool) after creating the Pool.","message":"Missing `setClient()` call before any operation causes a runtime error: Cannot read property 'query' of undefined.","severity":"gotcha","affected_versions":"<=1.0.5"},{"fix":"Consider migrating to a maintained alternative like pg-promise, knex, or slonik.","message":"The package has no active maintenance; no updates since initial release.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Wrap calls in try-catch or use .catch().","message":"The package does not support async/await natively (promises returned are from pg queries, but no error handling wrappers).","severity":"breaking","affected_versions":"<=1.0.5"}],"env_vars":null,"search_vec":"'1.0.5':24 'activ':28 'altern':76 'around':8 'avoid':48 'basic':52 'builder':58 'client':39 'configur':43 'connect':62 'crud':14 'develop':29 'featur':87 'feature-rich':86 'flexibl':59 'function':16 'github':32 'grade':75 'helper':4,15 'insert':17 'javascript':91 'knex':78 'like':77 'maintain':90 'migrat':60 'must':41 'node':2,10 'node-pg-help':1 'node-postgr':9 'nodej':92 'observ':30 'offer':55 'oper':53 'pg':3,37,82 'pg-promis':81 'pool':38,63 'postgr':11,93 'postgresql':22 'product':74 'production-grad':73 'promis':83 'prototyp':70 'provid':12 'queri':57 'quick':69 'raw':49 'releas':25 'reli':34 'rich':88 'selectallrow':20 'set':45 'setclient':47 'simplifi':13 'slonik':79 'small':6 'sql':50 'suitabl':67 'updat':18 'upsert':19 'version':23 'via':46 'wrapper':7","created_at":"2026-06-05T16:59:51.057597+00:00","updated_at":"2026-06-05T16:59:51.057597+00:00","problems":[{"fix":"Use const db = require('node-pg-helper');","cause":"Importing incorrectly (e.g., using ES import syntax or destructuring).","error":"TypeError: db.setClient is not a function"},{"fix":"Call db.setClient(pool) after creating the pool.","cause":"setClient() not called before performing a database operation.","error":"Cannot read property 'query' of undefined"},{"fix":"Ensure the data argument is a plain object with key-value pairs.","cause":"Passing a non-object as data (e.g., array or string) to insert/upsert/update.","error":"Error: insert requires an object"}],"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/wherrera/node-pg-helper#readme","github":"https://github.com/wherrera/node-pg-helper","docs":null,"changelog":null,"pypi":null,"npm":"node-pg-helper","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}}