Registry / database / pg-aa
library2.1.6jsnpmunverified

An ES7 wrapper for node-postgres that provides a simplified, promise-based API for common PostgreSQL operations including select, insert, update, delete, and transaction management with savepoint support. Current stable version is 2.1.6. The library is minimal (< 150 lines) and relies on async/await. It supports nested transactions via savepoints and works with template string engines like sql-template. Key differentiators: very thin abstraction over node-postgres, no ORM features, pure async/await pattern.

npm install pg-aa
INSTALL
IMPORT
SIG · PG-AA
P
pg-aa
databasejavascriptv2.1.6
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 pg from 'pg-aa'
const pg = require('pg-aa')
Default import for ES modules; commonjs require also works
pg
var pg = require('pg-aa')
var pg = require('pg-aa').default
CommonJS require returns the class directly
Client
import pg from 'pg-aa'
import { Client } from 'pg-aa'
The package exports a single class; no named exports

Connect to PostgreSQL using pg-aa, query a row, insert a log, select all active users.

import pg from 'pg-aa'; import SQL from 'sql-template'; const conString = "postgres://postgres:1234@localhost/postgres"; const client = new pg(conString); (async () => { const line = await client.row(SQL`SELECT * FROM users WHERE id=${22}`); if (!line) throw new Error("Missing user"); await client.insert("users_log", { user_id: 22, time: Date.now(), }); const rows = await client.select('users', { active: true }); console.log(rows); await client.end(); })().catch(console.error);
Debug
Known issues
gotchaThe package exports a single class as default; attempting to destructure or import named exports will fail.
fix
Use default import or require directly: import pg from 'pg-aa'
affects: >=0.0.0
gotchaConnection string must include credentials; no pooling configuration is exposed.
fix
Use a full connection string like 'postgres://user:pass@localhost/db'
affects: >=0.0.0
deprecatedThe .end() method must be called to close the client connection; forgetting causes hanging processes.
fix
Always call client.end() after finishing queries.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: pg_aa_1.default is not a constructor
Using wrong import style (e.g., named import) when default is expected.
fix
Use import pg from 'pg-aa' instead of import { pg } from 'pg-aa'
Cannot read property 'query' of undefined
Forgot to call new pg(conString) or provided invalid connection string.
fix
Ensure you create an instance: const client = new pg(conString)
Upgrade
Version history
2.1.6latest on npm
Audit
Dependencies
pgrequiredUnderlying PostgreSQL driver; pg-aa is a wrapper around node-postgres
debugoptionalUsed for debugging/logging
Agent activity
4 hits · last 30 days
node
4
Resources
packagepg-aa
pg-aa — npm install pg-aa · libregistry