Registry / database / systemic-pg

systemic-pg

JSON →
library3.0.0jsnpmunverified

A systemic component for PostgreSQL, wrapping the pg library to integrate with the systemic dependency injection framework. Current stable version is 3.0.0. It provides lifecycle management (start/stop), configuration via systemic config, and supports onConnect queries. Built on top of the pg npm package, it is designed for Node.js applications using systemic. Alternative direct usage of pg without systemic would require manual connection pooling and lifecycle handling.

npm install systemic-pg
INSTALL
IMPORT
SIG · SYSTEMIC-PG
S
systemic-pg
databasejavascriptv3.0.0
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.

systemic-pg (default)
const postgres = require('systemic-pg')
CommonJS default import for the systemic component factory
systemic-pg (ESM)
import postgres from 'systemic-pg'
import { postgres } from 'systemic-pg'
ESM default import; named export is not available
systemic (System)
const System = require('systemic')
Peer dependency for creating the systemic container

Creates a systemic system with PostgreSQL component, configures connection, starts, queries, and stops.

const System = require('systemic'); const postgres = require('systemic-pg'); const system = new System(); system .configure({ postgres: { host: 'localhost', database: 'example', onConnect: ["SET client_min_messages = WARNING", "SET search_path = custom,public"] } }) .add('logger', console) .add('postgres', postgres()).dependsOn('config', 'logger') .start((err, components) => { if (err) { console.error(err); process.exit(1); } // Use components.pg to query components.pg.query('SELECT NOW()', (err, result) => { if (err) throw err; console.log(result.rows); system.stop(() => process.exit(0)); }); });
Debug
Known issues
breakingVersion 3.0 drops support for Node.js < 10 and upgrades pg to v8.
fix
Upgrade to Node.js >=10 and ensure your pg usage is compatible with pg v8.
affects: >=3.0.0
breakingThe component property name changed from 'pg' to 'postgres' in some configurations.
fix
Update references from components.pg to components.postgres if using v2+.
affects: >=2.0.0
deprecatedThe onConnect feature may be superseded by pg pool event emitters.
fix
Consider using pg's 'connect' event on the pool for custom setup.
affects: >=1.0.0
gotchaThe component requires both systemic and pg as peer dependencies.
fix
Install both: npm install systemic pg
affects: >=1.0.0
gotchaIf you forget to call postgres() as a function, the component will fail silently.
fix
Ensure you pass postgres() (invoked) to .add(), not postgres itself.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'systemic-pg'
Package not installed or missing from node_modules.
fix
npm install systemic-pg
TypeError: postgres is not a function
Importing the default export incorrectly or using a named import in ESM.
fix
Use `import postgres from 'systemic-pg'` (default import).
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies
pgrequiredPeer dependency for PostgreSQL client
systemicrequiredPeer dependency for systemic framework integration
Agent activity
18 hits · last 30 days
node
14
Meta
2
Amazon
1
OpenAI (training)
1
Resources
systemic-pg — npm install systemic-pg · libregistry