Registry / database / zag-backend-pg

zag-backend-pg

JSON →
library1.0.0jsnpmunverified

PostgreSQL backend for the zag metrics system, providing persistent storage and querying for time-series metrics data. Current stable version 1.0.0 requires TimescaleDB for hypertable support. Release cadence is low, as the package appears stable and mature. Key differentiator: integrates directly with zag's metrics pipeline, leveraging PostgreSQL and TimescaleDB for efficient time-series storage.

npm install zag-backend-pg
INSTALL
IMPORT
SIG · ZAG-BACKEND-PG
Z
zag-backend-pg
databasejavascriptv1.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.

Backend
import Backend from 'zag-backend-pg'
const Backend = require('zag-backend-pg')
Package uses CommonJS exports; default import works in both ESM and CJS.
Backend
const Backend = require('zag-backend-pg')
CommonJS require is the traditional way; still supported in v1.

Creates a new PostgreSQL backend instance, connects to the database using environment variables for configuration.

const Backend = require('zag-backend-pg'); const backend = new Backend({ host: process.env.PG_HOST ?? 'localhost', port: parseInt(process.env.PG_PORT ?? '5432'), database: process.env.PG_DB ?? 'zag', user: process.env.PG_USER ?? 'postgres', password: process.env.PG_PASS ?? '' }); backend.connect().then(() => { console.log('Connected to PostgreSQL metrics backend'); });
Debug
Known issues
gotchaRequires TimescaleDB to be installed and available in PostgreSQL; setup script will fail without it.
fix
Install TimescaleDB extension in PostgreSQL before running setup.
affects: >=1.0.0
gotchaSetup script must be run before using the backend to create tables and indices; otherwise queries will fail.
fix
Run `./bin/setup.js` with appropriate database connection parameters.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'zag'
Missing the core 'zag' package as a dependency.
fix
Install 'zag' alongside 'zag-backend-pg': npm install zag zag-backend-pg
Error: relation "metrics" does not exist
Setup script has not been run or database not initialized.
fix
Run the setup script `./bin/setup.js` against your PostgreSQL database.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
zagrequiredCore metrics library this backend extends
pgrequiredPostgreSQL client for Node.js
Agent activity
29 hits · last 30 days
node
26
OpenAI (training)
1
Resources
zag-backend-pg — npm install zag-backend-pg · libregistry