Registry / database / easy-pg-scanner

easy-pg-scanner

JSON →
library1.0.9jsnpmunverified

Easy PG Scanner (v1.0.9) is a Node.js package for reading PostgreSQL database schemas into a structured array. It retrieves tables, columns, functions, triggers, indexes, check constraints, and foreign keys in a single asynchronous call. Currently in early release with monthly updates. Alternative to tools like pg-structure, with a simpler API and no external dependencies beyond pg. Ships TypeScript types.

npm install easy-pg-scanner
INSTALL
IMPORT
SIG · EASY-PG-SCANNER
E
easy-pg-scanner
databasejavascriptv1.0.9
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.

loadDatabase
✓ import loadDatabase from 'easy-pg-scanner'
✗ const loadDatabase = require('easy-pg-scanner')
Package is ESM-only since v1.0.0; default export is a function.
loadDatabase
✓ const loadDatabase = require('easy-pg-scanner').default
✗ const loadDatabase = require('easy-pg-scanner')
In CommonJS with ES modules, you must use .default to access the default export.
LoadDatabaseOptions
✓ import type { LoadDatabaseOptions } from 'easy-pg-scanner'
✗ import { LoadDatabaseOptions } from 'easy-pg-scanner'
Options type is exported as a type; use 'import type' for type-only imports.
DatabaseSchema
✓ import type { DatabaseSchema, Schema } from 'easy-pg-scanner'
✗ import { Schema } from 'easy-pg-scanner'
Schema is a type, not a value; use 'import type'.

Demonstrates connecting to a PostgreSQL database and fetching its full schema as a structured array using loadDatabase.

import loadDatabase from 'easy-pg-scanner'; const connectionOptions = { host: process.env.PG_HOST ?? 'localhost', port: Number(process.env.PG_PORT) || 5432, user: process.env.PG_USER ?? 'postgres', password: process.env.PG_PASSWORD ?? '', database: process.env.PG_DATABASE ?? 'postgres', }; async function main() { try { const database = await loadDatabase(connectionOptions); console.log(JSON.stringify(database, null, 2)); } catch (error) { console.error('Error loading database:', error); } } main();
Debug
Known issues
breakingPackage uses ES modules; requires 'type': 'module' in package.json or .mjs extension. Node.js >=12.0 required. Cannot be required() directly in CJS without dynamic import.
fix
Set 'type': 'module' in package.json or rename file to .mjs. For CJS, use const loadDatabase = (await import('easy-pg-scanner')).default;
affects: >=1.0.0
gotchaloadDatabase does not validate connection options; malformed or incomplete options will cause runtime errors from pg. No error messages are customized.
fix
Ensure all required connection fields (host, port, user, password, database) are provided and valid. Use try-catch around the call.
affects: <=1.0.9
deprecatedThe 'checkConstraints' property may be renamed in future versions. Check changelog before upgrading.
fix
Monitor GitHub releases; adapt code when property name changes.
affects: >=1.0.0
gotchaAll returned schema names are lowercase; if your database uses mixed-case schema names, they will be lowercased. This may cause mismatches.
fix
Query raw information_schema if you need original casing.
affects: <=1.0.9
Errors
Common errors & fixes
SyntaxError: Cannot use import statement outside a module
File is not configured as an ES module (no 'type': 'module' or .mjs extension).
fix
Add "type": "module" to package.json or rename the file to .mjs.
TypeError: loadDatabase is not a function
CommonJS require() returns an object with a default property; you must access .default.
fix
Use const loadDatabase = require('easy-pg-scanner').default;
error: password authentication failed for user '...'
Incorrect password or missing pg_hba.conf configuration.
fix
Double-check password in connection options and ensure pg_hba.conf allows password authentication.
Error: getaddrinfo ENOTFOUND ...
Hostname is incorrect or DNS resolution fails.
fix
Check the host field in connection options; ensure database server is reachable.
Upgrade
Version history
1.0.9latest on npm
Audit
Dependencies
pgoptionalpeer dependency for PostgreSQL client connection
Agent activity
6 hits · last 30 days
node
6
Resources
easy-pg-scanner — npm install easy-pg-scanner · libregistry