Registry / database / pg-parade

pg-parade

JSON →
library0.4.3jsnpmunverified

pg-parade (v0.4.3, last updated in 2017) wraps pg-promise to provide read/write replica support for PostgreSQL connections. It allows explicit routing of SELECT queries to read replicas and INSERT/UPDATE/DELETE to write replicas, with automatic fallback of reads to the write server during transactions. Key differentiators include a simple API with `.read` and `.write` scope objects and support for replica selection via a function returning a promise. However, the package is unmaintained and not compatible with modern pg-promise or async/await patterns.

npm install pg-parade
INSTALL
IMPORT
SIG · PG-PARADE
P
pg-parade
databasejavascriptv0.4.3
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
const pgParade = require('pg-parade');
The package exports a factory function as default. CommonJS require is the standard pattern for this package.
default
import pgParade from 'pg-parade';
import { pgParade } from 'pg-parade';
This package does not ship TypeScript types; named import will fail.
db.read
const db = pgParade()({ write: '...', read: '...' }); db.read.query('SELECT ...');
db.query('SELECT ...');
Direct db.query does not exist; you must specify db.read or db.write explicitly.

Shows basic read/write replica setup and usage with pg-parade, including a transaction where reads are redirected to the write server.

const pgp = require('pg-parade')(); const db = pgp({ write: 'postgres://localhost:5432/write_db', read: 'postgres://localhost:5433/read_db' }); // Write query goes to write replica db.write.query('INSERT INTO users (name) VALUES ($1)', ['Alice']) .then(() => console.log('Inserted')) .catch(err => console.error(err)); // Read query goes to read replica db.read.query('SELECT * FROM users') .then(rows => console.log(rows)) .catch(err => console.error(err)); // In transactions, reads are redirected to write replica db.tx(t => { return t.read.one('SELECT count(*) FROM users') .then(count => t.write.none('UPDATE users SET active = true')); });
Debug
Known issues
deprecatedPackage is unmaintained; last update 2017. Not compatible with current pg-promise versions or Node.js >= 12.
fix
Migrate to pg-promise with manual replica routing or use a maintained alternative.
affects: >=0.4.0
breakingdb.query() does not exist; you must call db.read.query() or db.write.query().
fix
Always use .read or .write scope before query method.
affects: *
gotchaTransactions force all read queries to the write replica; reads inside tx are never sent to the read replica.
fix
Design application to handle this behavior; avoid assuming read isolation in transactions.
affects: *
Errors
Common errors & fixes
Cannot find module 'pg-parade'
Missing npm install or package not in node_modules.
fix
Run 'npm install pg-parade'
pgParade is not a function
Using ES6 named import instead of default import.
fix
Use 'import pgParade from 'pg-parade'' or 'const pgParade = require('pg-parade')()'
Cannot read property 'query' of undefined
Calling db.query directly instead of db.read.query or db.write.query.
fix
Use db.read.query for SELECT, db.write.query for INSERT/UPDATE/DELETE.
Upgrade
Version history
0.4.3latest on npm
Audit
Dependencies
pg-promiserequiredpg-parade wraps pg-promise for database connectivity and replication routing.
Agent activity
4 hits · last 30 days
node
4
Resources
pg-parade — npm install pg-parade · libregistry