Registry / database / postgres-wrapper

postgres-wrapper

JSON →
library1.0.4jsnpmunverified

A lightweight, zero-dependency wrapper around the `pg` (node-postgres) library for Node.js, providing simplified CRUD methods (`one`, `oneOrNone`, `any`, `many`, `none`) and automatic connection management via a single `POSTGRES_URL` environment variable. Version 1.0.4 is the latest stable release. It is designed for quick prototyping and small projects, with minimal API surface and no ORM features. Key differentiator: instant setup with environment variables, no configuration files required.

database
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.

The package only provides a CommonJS export. Named exports are not available.

const pg = require('postgres-wrapper')

All methods expect a single object argument with `query` and optional `params` keys.

const object = await pg.one({ query, params })

Do not use raw pg client methods; the wrapper handles connection and cleanup.

const rows = await pg.any({ query, params })

Demonstrates basic usage: importing the module, querying a single row, and closing the connection.

const pg = require('postgres-wrapper'); async function run() { try { const user = await pg.one({ query: 'SELECT * FROM users WHERE id = $1', params: [1] }); console.log(user); await pg.end(); } catch (err) { console.error(err); } } run();
Debug
Known footguns
breakingEnvironment variable POSTGRES_URL must be set at runtime; failure to set it causes immediate connection error.
gotchaEach query method creates a new connection pool internally if not already connected; calling pg.end() is required to avoid resource leaks.
deprecatedThe package has no TypeScript typings; users must write their own declarations or use @types/pg.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
6 hits · last 30 days
gptbot
3
Resources