{"id":42675,"library":"easy-pg-scanner","title":"Easy PG Scanner","description":"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.","status":"active","version":"1.0.9","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","typescript"],"install":[{"cmd":"npm install easy-pg-scanner","lang":"bash","label":"npm"},{"cmd":"yarn add easy-pg-scanner","lang":"bash","label":"yarn"},{"cmd":"pnpm add easy-pg-scanner","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency for PostgreSQL client connection","package":"pg","optional":true}],"imports":[{"note":"Package is ESM-only since v1.0.0; default export is a function.","wrong":"const loadDatabase = require('easy-pg-scanner')","symbol":"loadDatabase","correct":"import loadDatabase from 'easy-pg-scanner'"},{"note":"In CommonJS with ES modules, you must use .default to access the default export.","wrong":"const loadDatabase = require('easy-pg-scanner')","symbol":"loadDatabase","correct":"const loadDatabase = require('easy-pg-scanner').default"},{"note":"Options type is exported as a type; use 'import type' for type-only imports.","wrong":"import { LoadDatabaseOptions } from 'easy-pg-scanner'","symbol":"LoadDatabaseOptions","correct":"import type { LoadDatabaseOptions } from 'easy-pg-scanner'"},{"note":"Schema is a type, not a value; use 'import type'.","wrong":"import { Schema } from 'easy-pg-scanner'","symbol":"DatabaseSchema","correct":"import type { DatabaseSchema, Schema } from 'easy-pg-scanner'"}],"quickstart":{"code":"import loadDatabase from 'easy-pg-scanner';\n\nconst connectionOptions = {\n  host: process.env.PG_HOST ?? 'localhost',\n  port: Number(process.env.PG_PORT) || 5432,\n  user: process.env.PG_USER ?? 'postgres',\n  password: process.env.PG_PASSWORD ?? '',\n  database: process.env.PG_DATABASE ?? 'postgres',\n};\n\nasync function main() {\n  try {\n    const database = await loadDatabase(connectionOptions);\n    console.log(JSON.stringify(database, null, 2));\n  } catch (error) {\n    console.error('Error loading database:', error);\n  }\n}\n\nmain();","lang":"typescript","description":"Demonstrates connecting to a PostgreSQL database and fetching its full schema as a structured array using loadDatabase."},"warnings":[{"fix":"Set 'type': 'module' in package.json or rename file to .mjs. For CJS, use const loadDatabase = (await import('easy-pg-scanner')).default;","message":"Package 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.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Ensure all required connection fields (host, port, user, password, database) are provided and valid. Use try-catch around the call.","message":"loadDatabase does not validate connection options; malformed or incomplete options will cause runtime errors from pg. No error messages are customized.","severity":"gotcha","affected_versions":"<=1.0.9"},{"fix":"Monitor GitHub releases; adapt code when property name changes.","message":"The 'checkConstraints' property may be renamed in future versions. Check changelog before upgrading.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Query raw information_schema if you need original casing.","message":"All returned schema names are lowercase; if your database uses mixed-case schema names, they will be lowercased. This may cause mismatches.","severity":"gotcha","affected_versions":"<=1.0.9"}],"env_vars":null,"search_vec":"'altern':45 'api':55 'array':20 'asynchron':36 'beyond':60 'call':37 'check':28 'column':24 'constraint':29 'current':38 'databas':15 'depend':59 'earli':40 'easi':1,4 'extern':58 'foreign':31 'function':25 'index':27 'javascript':65 'key':32 'like':48 'month':43 'node.js':10 'packag':11 'pg':2,5,50,61 'pg-structur':49 'postgresql':14 'read':13 'releas':41 'retriev':22 'scanner':3,6 'schema':16 'ship':62 'simpler':54 'singl':35 'structur':19,51 'tabl':23 'tool':47 'trigger':26 'type':64 'typescript':63,66 'updat':44 'v1.0.9':7","created_at":"2026-06-05T16:56:07.343602+00:00","updated_at":"2026-06-05T16:56:07.343602+00:00","problems":[{"fix":"Add \"type\": \"module\" to package.json or rename the file to .mjs.","cause":"File is not configured as an ES module (no 'type': 'module' or .mjs extension).","error":"SyntaxError: Cannot use import statement outside a module"},{"fix":"Use const loadDatabase = require('easy-pg-scanner').default;","cause":"CommonJS require() returns an object with a default property; you must access .default.","error":"TypeError: loadDatabase is not a function"},{"fix":"Double-check password in connection options and ensure pg_hba.conf allows password authentication.","cause":"Incorrect password or missing pg_hba.conf configuration.","error":"error: password authentication failed for user '...'"},{"fix":"Check the host field in connection options; ensure database server is reachable.","cause":"Hostname is incorrect or DNS resolution fails.","error":"Error: getaddrinfo ENOTFOUND ..."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"easy-pg-scanner","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}