Registry / database / q-postgres

q-postgres

JSON →
library1.0.4jsnpmunverified

A thin promise-based wrapper around the pg (node-postgres) library that provides a connection pool and transaction management with commit/rollback support. Current version 1.0.4 targets Node 4.3.1+ and npm 3.7.3+. It uses raw promises (no async/await) and is designed for simple PostgreSQL interaction in legacy Node.js environments. Compared to alternatives like pg-promise or sequelize, it offers minimal abstraction, no query building, and no connection monitoring. The package is in maintenance mode with no recent updates and is suitable only for projects locked to older Node versions.

npm install q-postgres
INSTALL
IMPORT
SIG · Q-POSTGRES
Q
q-postgres
databasejavascriptv1.0.4
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.

qPostgres
const qPostgres = require('q-postgres');
import qPostgres from 'q-postgres';
Package is CJS-only and does not support ESM imports. Named import also works via destructuring.
default
const qPostgres = require('q-postgres');
import * as qPostgres from 'q-postgres';
The module exports a single constructor function. Using require() is the intended way.
Pool
const qPostgres = require('q-postgres');
const { Pool } = require('q-postgres');
Pool is not exported as a named export; the entire module is the Pool constructor.

Shows creating a pool, getting a connection, opening a transaction, running a query, committing, and releasing the connection.

const qPostgres = require('q-postgres'); const pool = new qPostgres( 'user', 'password', 'localhost', 'database', process.env.DATABASE_URL ?? '' ); pool.connect().then((conn) => { conn.openTransaction().then((tx) => { return tx.runScript('SELECT NOW()').then((result) => { console.log(result.rows); return tx.commit(); }); }).then(() => conn.end()); }).catch(err => console.error(err));
Debug
Known issues
breakingOnly supports Node.js ~4.3.1 and npm ~3.7.3; will not run on modern Node versions.
fix
Use a newer library like pg-promise or knex for modern Node environments.
affects: >=1.0.0
deprecatedPackage uses callbacks-like promise chains; no support for async/await or newer JavaScript features.
fix
Consider migrating to a promise-based library that supports async/await (e.g., pg-promise).
affects: >=1.0.0
gotchaThe pool constructor expects database URL as the last argument; it's easy to omit or pass incorrectly.
fix
Always provide all five arguments: user, password, host, database, and optional URL.
affects: >=1.0.0
gotchaTransaction rollback is done by calling connection.rollback() inside a catch; forgetting to catch causes unhandled rejections.
fix
Attach .catch(transaction.rollback) to the promise chain as shown in the README.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'q-postgres'
Package not installed or wrong package name.
fix
Run 'npm install q-postgres' and ensure it's in node_modules.
TypeError: qPostgres is not a constructor
Attempting to use named exports (e.g., { qPostgres }) instead of the entire module.
fix
Use 'const qPostgres = require('q-postgres');' without destructuring.
Error: getaddrinfo ENOTFOUND localhost
Host 'localhost' not resolved or PostgreSQL not running.
fix
Ensure PostgreSQL server is running and accessible; use an IP address or proper hostname.
Upgrade
Version history
1.0.4latest on npm
Audit
Dependencies
pgrequiredpeer dependency for PostgreSQL client
Agent activity
9 hits · last 30 days
node
6
Resources
q-postgres — npm install q-postgres · libregistry