Registry / database / database-js-postgres

database-js-postgres

JSON →
library1.1.3jsnpmunverified

database-js-postgres is a wrapper library designed to integrate PostgreSQL databases with the database-js framework. It utilizes the widely adopted node-postgres package under the hood to handle core database interactions, exposing its functionality through a consistent promise-based API, even when used independently of database-js. The library reached its latest stable version, 1.1.3, in late 2017. Given the lack of updates or commits since then, its release cadence is effectively ceased, and the project is considered unmaintained. Its primary differentiation was to provide a standardized interface within the database-js ecosystem, enabling a uniform approach to various SQL databases. However, its dependency on outdated Node.js versions and its CommonJS-only structure limit its applicability in modern JavaScript environments.

npm install database-js-postgres
INSTALL
IMPORT
SIG · DATABASE-JS-POSTGR
D
database-js-postgres
databasejavascriptv1.1.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

postgres
const postgres = require('database-js-postgres');
import postgres from 'database-js-postgres';
Package is CommonJS-only; direct ESM import is not supported.
Connection
const Database = require('database-js2').Connection;
import { Connection } from 'database-js2';
When using with database-js, the Connection class is imported from 'database-js2' as shown in the original documentation. This is a CommonJS require.
Connection (standalone)
const postgres = require('database-js-postgres'); const connection = postgres.open({ ... });
import { open } from 'database-js-postgres'; const connection = open({ ... });
The `open` method for standalone usage is accessed via the default export of the package, not a named export. Requires CommonJS.

Demonstrates connecting to a PostgreSQL database, executing a SELECT query with parameters, performing an INSERT operation, and properly closing the connection using the standalone promise-based API.

const postgres = require('database-js-postgres'); (async () => { let connection, rows; // Establish a connection to the PostgreSQL database connection = postgres.open({ Hostname: 'localhost', Port: 5432, Username: 'my_secret_username', Password: 'my_secret_password', Database: 'my_top_secret_database' }); try { // Execute a query and fetch results rows = await connection.query("SELECT id, name FROM users WHERE email = ?", ['example@email.com']); console.log('Query Results:', rows); // Example of an insert statement const insertResult = await connection.query("INSERT INTO logs (message) VALUES (?) RETURNING id", ['User logged in successfully']); console.log('Insert Result:', insertResult); } catch (error) { console.error('Database Operation Error:', error); } finally { // Always ensure the connection is closed await connection.close(); console.log('Connection closed.'); } })();
Debug
Known issues
breakingThe package `database-js-postgres` has been abandoned since late 2017. It no longer receives updates, bug fixes, or security patches. Using it in production is highly discouraged.
fix
Migrate to a currently maintained PostgreSQL driver like `node-postgres` directly or a well-supported ORM/query builder.
affects: >=1.1.3
gotchaThe documentation specifies a prerequisite of 'NodeJS >= 6.0'. Modern Node.js versions are not guaranteed to be compatible, and using such an old Node.js version is a significant security risk.
fix
Avoid using this package with modern Node.js versions. If forced to use, thorough testing is required, but migration is the recommended path.
affects: >=1.0.0
gotchaThis package is CommonJS-only and does not support ES Modules (ESM) syntax (`import/export`). Attempting to use ESM will result in errors.
fix
Use CommonJS `require()` syntax for all imports. For projects requiring ESM, consider alternative, actively maintained libraries.
affects: >=1.0.0
gotchaWhen used with `database-js`, the README explicitly imports from `database-js2`. Ensure the correct package (`database-js` or `database-js2`) is installed and matched to the example's usage, as this can be a source of confusion.
fix
Verify your `package.json` dependencies and import paths to match the documented `require('database-js2').Connection;` if integrating with the parent framework.
affects: >=1.0.0
Errors
Common errors & fixes
Error: connect ECONNREFUSED
The PostgreSQL server is not running, is not accessible from the application's host, or the specified port is incorrect.
fix
Verify that your PostgreSQL server is running, listening on the specified host and port (default 5432), and that no firewall is blocking the connection.
Error: password authentication failed for user "my_secret_username"
Incorrect username or password, or the PostgreSQL server's `pg_hba.conf` configuration does not allow the specified authentication method for the user/database.
fix
Double-check the username and password in your connection string. Consult your PostgreSQL server's `pg_hba.conf` file to ensure the client IP address and user are permitted to connect with password authentication (e.g., `md5`, `scram-sha-256`).
Cannot find module 'database-js-postgres'
The package is not installed or `npm install` was not run.
fix
Run `npm install database-js-postgres` in your project directory to install the package.
Upgrade
Version history
1.1.3latest on npm
Audit
Dependencies
node-postgresrequiredCore underlying PostgreSQL driver
database-jsrequiredParent framework it's designed to integrate with (often imported as 'database-js2' in examples, likely referring to a specific version or alias)
Agent activity
9 hits · last 30 days
node
8
Amazon
1
Resources
database-js-postgres — npm install database-js-postgres · libregistry