Registry / database / dboa-js

dboa-js

JSON →
library0.5.1jsnpmunverified

A utility module for cleaning up messy PostgreSQL databases by analyzing table statistics, detecting anomalies, and generating reports. The current stable version is 0.5.1, released with a moderate cadence. Key differentiators include a focus on Postgres-specific cleanup tasks such as duplicate removal, missing foreign key detection, and orphan record identification, with a simple API for integration into data maintenance workflows.

npm install dboa-js
INSTALL
IMPORT
SIG · DBOA-JS
D
dboa-js
databasejavascriptv0.5.1
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 dboa from 'dboa-js'
const dboa = require('dboa-js')
ESM-only package; CommonJS require will fail.
createAnalyzer
import { createAnalyzer } from 'dboa-js'
const createAnalyzer = require('dboa-js').createAnalyzer
Named export available since v0.5.0.
cleanDuplicates
import { cleanDuplicates } from 'dboa-js'
import cleanDuplicates from 'dboa-js'
Not default export; must be destructured.

Connects to a Postgres database, analyzes a table for duplicates and nulls, and removes duplicates if found.

import { createAnalyzer, cleanDuplicates } from 'dboa-js'; import pg from 'pg'; const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL ?? '' }); const analyzer = createAnalyzer(pool); const report = await analyzer.analyzeTable('users', { checkForNulls: true, checkForDuplicates: true }); console.log(report); if (report.duplicates?.length) { const cleaned = await cleanDuplicates(pool, 'users', report.duplicates[0].columns); console.log(`Removed ${cleaned.deleted} duplicate rows.`); } await pool.end();
Debug
Known issues
breakingDatabase schema modifications are irreversible. Always backup before running cleanup operations.
fix
Run in a transaction and verify the report first.
affects: >=0.1.0
deprecatedThe method `analyze` (without table parameter) is deprecated since v0.4.0. Use `analyzeTable` instead.
fix
Replace `analyze()` with `analyzeTable(tableName, options)`.
affects: >=0.4.0
gotchaOnly PostgreSQL databases are supported. Using with other SQL databases will result in runtime errors due to Postgres-specific queries.
fix
Ensure your database is PostgreSQL and the connection uses the `pg` driver.
affects: >=0.1.0
gotchaThe module uses `pg.Pool` internally. Passing a client instead of a pool may cause connection leaks.
fix
Always pass a `pg.Pool` instance, not a single `pg.Client`.
affects: >=0.1.0
Errors
Common errors & fixes
Cannot find module 'dboa-js'
Package not installed or ESM import used in a CommonJS project.
fix
Install with `npm install dboa-js` and ensure your project is configured for ESM (add `"type":"module"` to package.json or use .mjs extension).
cleanDuplicates is not a function
Named import incorrectly used as default import.
fix
Use `import { cleanDuplicates } from 'dboa-js'` instead of `import cleanDuplicates from 'dboa-js'`.
Error: getaddrinfo ENOTFOUND localhost
Postgres not running or connection string is incorrect.
fix
Check that PostgreSQL is running and the DATABASE_URL environment variable is set correctly (e.g., `postgres://user:pass@localhost:5432/dbname`).
Upgrade
Version history
0.5.1latest on npm
Audit
Dependencies
pgrequiredPostgreSQL client for database connection
Agent activity
8 hits · last 30 days
node
6
Resources
dboa-js — npm install dboa-js · libregistry