Registry / database / jsreport-postgres-store

jsreport-postgres-store

JSON →
library1.4.0jsnpmunverified

A jsreport extension that persists templates and reports in PostgreSQL. Current stable version is 1.4.0, release cadence is low (last release in 2019). Acts as a data store provider alternative to the default filesystem or MongoDB. Requires a running PostgreSQL instance and manual schema migration on extension changes. Not actively maintained but still functional with jsreport-core.

npm install jsreport-postgres-store
INSTALL
IMPORT
SIG · JSREPORT-POSTGRES-
J
jsreport-postgres-store
databasejavascriptv1.4.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.

default
import postgresStore from 'jsreport-postgres-store'
const postgresStore = require('jsreport-postgres-store').default
CommonJS: const postgresStore = require('jsreport-postgres-store')
require (CommonJS)
const postgresStore = require('jsreport-postgres-store')
const { postgresStore } = require('jsreport-postgres-store')
Package exports a single function, not an object
JavaScript
jsreport.use(require('jsreport-postgres-store'))
jsreport.use(require('jsreport-postgres-store').default)
No `.default` needed in CommonJS

Initializes jsreport-core with the PostgreSQL store and inserts a template.

const jsreport = require('jsreport-core')(); jsreport.use(require('jsreport-postgres-store')({ host: process.env.PGHOST || 'localhost', port: process.env.PGPORT || 5432, database: process.env.PGDATABASE || 'jsreport', user: process.env.PGUSER || 'postgres', password: process.env.PGPASSWORD || '' })); const fs = require('fs'); const template = JSON.parse(fs.readFileSync('template.json', 'utf8')); jsreport.init().then(() => { return jsreport.documentStore.collection('templates').insert(template); }).then(() => { console.log('Template stored in PostgreSQL'); }).catch((e) => { console.error(e); });
Debug
Known issues
gotchaAfter changing schema (adding extensions), you must drop affected tables or jsreport may fail to reinitialize them.
fix
Manually drop tables (e.g., DROP TABLE IF EXISTS jsreport.TemplateType CASCADE;) and restart jsreport to recreate them.
affects: >=0.1.0
deprecatedPackage is not actively maintained; last release was in 2019. May not work with latest jsreport versions.
fix
Consider using jsreport-mongodb-store or filesystem store as alternatives.
affects: >=1.4.0
gotchaConfiguration must include 'store': { 'provider': 'postgres' } in jsreport config, otherwise the extension is loaded but not used.
fix
Set provider in store configuration: { "store": { "provider": "postgres" } }
affects: >=0.1.0
gotchaThe extension uses Node >= 8.9; using older Node versions will cause runtime errors.
fix
Upgrade Node.js to >= 8.9
affects: >=1.4.0
gotchaWhen using jsreport-core, the extension must be passed as a function invocation (with config) to use(), not just the module reference.
fix
Correct: jsreport.use(require('jsreport-postgres-store')({...}))
affects: >=0.1.0
Errors
Common errors & fixes
Error: provider not found: postgres
Missing store provider configuration or extension not loaded
fix
Set provider in jsreport config: { "store": { "provider": "postgres" } } and ensure extension is loaded with use()
Error: getaddrinfo ENOTFOUND localhost:5432
PostgreSQL server is not running or host/port is incorrect
fix
Ensure PostgreSQL is running and accessible. Check host, port, and network connectivity.
Error: role "postgres" does not exist
The specified user does not exist in PostgreSQL
fix
Create the user or provide valid credentials: CREATE ROLE postgres LOGIN PASSWORD 'password';
error: relation "jsreport.TemplateType" does not exist
Tables have not been created automatically, possibly because schema was manually dropped or extension is misconfigured
fix
Reinitialize: drop the schema if needed and restart jsreport. Ensure all extensions that affect schema are loaded before init.
Upgrade
Version history
1.4.0latest on npm
Audit
Dependencies
jsreport-corerequiredWorks as an extension to jsreport-core, providing the store interface
pgrequiredPostgreSQL client driver used for database communication
Agent activity
4 hits · last 30 days
node
4
Resources
jsreport-postgres-store — npm install jsreport-postgres-store · libregistry