Registry / database / qp-postgres

qp-postgres

JSON →
library1.1.8jsnpmunverified

qp-postgres is a lightweight PostgreSQL utility library for Node.js, version 1.1.8 as of latest release. It provides helper functions for common PostgreSQL operations, including connection pooling, query building, and transaction management. The package is designed to be minimal and dependency-free, relying only on the native pg library. It differentiates itself by focusing on a simple, functional API without heavy ORM features. Release cadence is irregular, with the last update likely inactive. Best for small projects needing straightforward PostgreSQL helpers.

npm install qp-postgres
INSTALL
IMPORT
SIG · QP-POSTGRES
Q
qp-postgres
databasejavascriptv1.1.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.

default
import qp from 'qp-postgres'
const qp = require('qp-postgres')
ESM module; CommonJS require may not work without transpilation.
query
import { query } from 'qp-postgres'
const { query } = require('qp-postgres')
Named export for executing queries.
pool
import { pool } from 'qp-postgres'
import pool from 'qp-postgres'
Named export for creating a connection pool, not default.

Shows how to create a pg Pool, run a simple query using qp.query, and log the result. Demonstrates ESM import and usage with environment variable for connection.

import qp from 'qp-postgres'; import { Pool } from 'pg'; const pool = new Pool({ connectionString: process.env.DATABASE_URL ?? 'postgresql://user:password@localhost:5432/mydb' }); async function main() { const result = await qp.query(pool, 'SELECT NOW()'); console.log(result.rows[0]); } main().catch(console.error);
Debug
Known issues
gotchaThe package assumes pg library is installed as a peer dependency; not including pg will cause runtime errors.
fix
Install pg: npm install pg
affects: >=1.0.0
deprecatedqp.query without explicit pool parameter may default to a global pool, which is deprecated and may be removed in future versions.
fix
Always pass the pool explicitly: qp.query(pool, text, params)
affects: >=1.1.0
gotchaTransactions must be manually committed or rolled back; there is no automatic rollback on error.
fix
Wrap transaction logic in try-catch and call pool.query('ROLLBACK') on error.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'query')
Missing pg dependency or pool not passed correctly.
fix
Install pg and ensure pool is provided to qp functions.
qp.default is not a function
Incorrect import syntax, e.g., using default import when only named exports exist.
fix
Use import * as qp from 'qp-postgres' or import { query } from 'qp-postgres'.
Upgrade
Version history
1.1.8latest on npm
Audit
Dependencies
pgrequiredPostgreSQL client for Node.js
Agent activity
6 hits · last 30 days
node
6
Resources
qp-postgres — npm install qp-postgres · libregistry