Registry / database / alinex-database

alinex-database

JSON →
library1.1.2jsnpmunverified

Alinex Database is a Node.js module that provides a comprehensive database abstraction layer, designed to simplify interactions with various relational database management systems (RDBMS) such as MySQL and PostgreSQL. Currently at version 1.1.2, this library offers key features including robust connection pooling, support for database clustering, automatic SSH tunneling for secure connections, and an object-to-query language builder. It aims for ease of configuration and use across different database types, integrating closely with the broader Alinex Namespace ecosystem for configuration management. While a specific release cadence isn't detailed, the project appears actively maintained, offering a stable API for its stated features. Its primary differentiators lie in its bundled advanced connection management capabilities and integrated query building, aiming to reduce boilerplate for common database operations.

database
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.

The primary way to import the library in v1.x, as shown in the documentation, is via CommonJS `require`. Direct ESM `import` might not be fully supported or require a CommonJS interop wrapper.

const database = require('alinex-database')

Database instances are obtained asynchronously through a static `instance` method on the main `database` export, utilizing a callback pattern, not via a constructor.

database.instance('connectionName', (err, db) => { /* ... */ })

Connections are acquired from the database pool via an asynchronous `connect` method on the database instance, also using a callback. Ensure this connection is released when done.

db.connect((err, conn) => { /* ... */ })

This quickstart demonstrates the core workflow: obtaining a database instance, connecting to it from the pool, executing a simple SQL query, and ensuring proper connection release and database instance closure using callback functions.

const database = require('alinex-database'); // This example assumes a 'test-mysql' configuration is set up // in your alinex-config. For example, in a config file: // database: // test-mysql: // type: 'mysql' // host: 'localhost' // user: 'root' // password: 'password' // database: 'test_db' database.instance('test-mysql', (err, db) => { if (err) { console.error('Error getting database instance:', err); return; } console.log('Database instance for "test-mysql" obtained.'); db.connect((err, conn) => { if (err) { console.error('Error connecting to database:', err); return; } console.log('Connected to database. Executing query...'); conn.query('SELECT 2 + 2 AS solution', (err, rows, fields) => { if (err) { console.error('Error executing query:', err); conn.release(); // Release connection even on query error return; } console.log('Query result: The database calculated 2+2 =', rows[0].solution); conn.release(); // Release connection back to the pool console.log('Connection released.'); db.close((err) => { if (err) { console.error('Error closing database:', err); return; } console.log('Database instance closed successfully.'); }); }); }); });
Debug
Known footguns
gotchaThe library's API is heavily callback-based. Developers accustomed to modern JavaScript's Promise-based or async/await patterns will need to manually wrap or promisify the asynchronous functions.
gotchaDatabase connection configurations are expected to be managed externally via the `alinex-config` module. Failing to provide a correct configuration for the requested instance name will lead to errors during instance creation.
gotchaAll database connections obtained from the pool via `db.connect()` must be explicitly released using `conn.release()` once they are no longer needed. Failure to release connections will lead to resource exhaustion and application instability.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
17 hits · last 30 days
bytedance
5
gptbot
4
ahrefsbot
4
script
1
bingbot
1
Resources