pg-db v2.0.0 is a helper module for node-postgres that adds transaction management, named parameter support, a simplified query API, and event hooks. It automatically returns connections to the pool and destroys connections on SQL errors. Transactions are implemented using Node.js domains, allowing different parts of an application to participate without manual context passing. Named parameters use :param syntax instead of $N. The package requires pg >= 7 as a peer dependency. No frequent releases; last update was years ago.
npm install pg-dbNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows creating a default database instance, executing a simple query with callback, and using named parameters.
Consider migrating to modern transaction patterns using pg's native transaction support or async/await with pg-promise.
Use var db = require('pg-db')(); instead of var db = require('pg-db');Use callbacks or wrap with util.promisify() for promise support.
Use :paramName in SQL and supply an object with matching keys.
Check the source or avoid using events in production until clarified.
Use var db = require('pg-db')(); (with parentheses).Set process.env.DATABASE_URL to a valid connection string, e.g., 'postgres://user:pass@localhost:5432/mydb'.
Ensure var db = require('pg-db')(); is used.