Registry / database / pg-helper

pg-helper

JSON →
library0.0.8jsnpmunverified

pg-helper is a minimal, low-level helper library for PostgreSQL in Node.js, providing simple query building and execution on top of the pg driver. Current stable version is 0.0.8; the project is in early development with infrequent releases. It offers basic CRUD operations and connection pool wrappers but is explicitly marked as experimental and potentially insecure (e.g., raw string interpolation for dynamic values). Compared to mature alternatives like knex, pg-promise, or slonik, it lacks validation, escape helpers, migration support, and advanced features. Suitable only for prototyping or trivial scripts where security is not a concern.

npm install pg-helper
INSTALL
IMPORT
SIG · PG-HELPER
P
pg-helper
databasejavascriptv0.0.8
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

createDb
import { createDb } from 'pg-helper'
const createDb = require('pg-helper').createDb
ESM-only package; CommonJS require does not work.
db
import { db } from 'pg-helper'
Default export is not available; only named exports.
query
import { query } from 'pg-helper'
const { query } = require('pg-helper')
Named export; must import using ESM syntax.

Shows how to initialize a database connection using createDb, execute raw queries, and retrieve results.

import { createDb } from 'pg-helper'; const db = createDb({ host: 'localhost', port: 5432, user: 'postgres', password: process.env.PGPASSWORD ?? '', database: 'testdb' }); async function run() { await db.query('CREATE TABLE IF NOT EXISTS users (id SERIAL PRIMARY KEY, name TEXT)'); await db.query("INSERT INTO users (name) VALUES ('Alice')"); const result = await db.query('SELECT * FROM users'); console.log(result.rows); await db.end(); } run().catch(console.error);
Debug
Known issues
deprecatedPackage is in early, experimental state; author warns about security holes and incomplete command support.
fix
Switch to a production-ready library like knex, pg-promise, or slonik.
affects: <=0.0.8
gotchaESM-only; cannot be imported via CommonJS require().
fix
Use dynamic import() or switch to ESM project.
affects: >=0.0.0
gotchaDirect string interpolation in queries may lead to SQL injection; no built-in parameterization or escaping.
fix
Always use parameterized queries with $1 etc. if supported, or migrate to a library with proper escaping.
affects: >=0.0.0
gotchaNo TypeScript type definitions shipped; developer must declare module manually.
fix
Create a .d.ts file or use a type-safe alternative.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'pg-helper'
Package not installed or wrong import path.
fix
Run `npm install pg-helper` and use ESM import syntax.
createDb is not a function
CommonJS require used instead of ESM import.
fix
Use `import { createDb } from 'pg-helper'` instead of `const { createDb } = require('pg-helper')`.
Upgrade
Version history
0.0.8latest on npm
Audit
Dependencies
pgrequiredpg-helper builds on top of the pg PostgreSQL client library for Node.js.
Agent activity
4 hits · last 30 days
node
4
Resources
pg-helper — npm install pg-helper · libregistry