Registry / database / database-utils

database-utils

JSON →
library1.4.1jsnpmunverified

This `database-utils` package is an **abandoned and unmaintained** Node.js utility library, last updated over a decade ago with version `1.4.1`. It aimed to provide fundamental tools for interacting with databases, including a `SqlBuilder` for constructing SQL queries programmatically and an `ORM` (Object Relational Mapper) for higher-level database interactions. However, its development ceased long ago, and the project's GitHub repository explicitly carries a deprecation notice, advising against its use for anything other than historical research. It does not follow modern best practices, lacks essential features (as indicated by its extensive `TODO` list), and likely has significant compatibility issues with contemporary Node.js versions and database systems. Users seeking database utilities, SQL builders, or ORMs should explore actively maintained alternatives in the Node.js ecosystem, such as `knex`, `sequelize`, `typeorm`, or `prisma`.

npm install database-utils
INSTALL
IMPORT
SIG · DATABASE-UTILS
D
database-utils
databasejavascriptv1.4.1
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.

SqlDriver
const SqlDriver = require('database-utils').SqlDriver;
import { SqlDriver } from 'database-utils';
The package likely pre-dates widespread ESM adoption and primarily uses CommonJS `require` for its `SqlDriver` class.
ORM
const ORM = require('database-utils').ORM; // Assuming direct export (not explicitly shown in README)
import ORM from 'database-utils';
While 'ORM' is mentioned as a feature, its exact export name and usage pattern are not clearly documented in the available README and might be incomplete or non-existent in practice. This is an inferred usage based on the mention.
DatabaseUtils
const DatabaseUtils = require('database-utils'); // To access all exports, if any
import DatabaseUtils from 'database-utils';
Given its age, it might expose multiple utilities as properties of the main `require` export, though `SqlDriver` appears to be the primary documented entry point for its SQL building capabilities.

Demonstrates basic SQL query construction using the `SqlDriver` class and how to retrieve both raw SQL and parameterized queries. It highlights the library's role as a SQL builder rather than a full database connector. The commented-out ORM section illustrates potential (but speculative) usage.

const { SqlDriver } = require('database-utils'); const sqlDriver = new SqlDriver(); // Example 1: Basic SELECT query let sql = sqlDriver .parameters() .select('*') .from('user') .where('id', 5) .get(); console.log('Generated SQL (Example 1):', sql); // Expected: select * from user where id = 5 // Example 2: SELECT query with parameterized values (demonstrating getQuerySql for prepared statements) let parameterizedSql = sqlDriver .parameters() .select('*') .from('products') .where('category', 'Electronics') .where('price', '>', 100) .getQuerySql(); let query = parameterizedSql[0]; let params = parameterizedSql[1]; console.log('\nGenerated SQL (Example 2 - Query):', query); // Expected: select * from products where category = ? and price > ? console.log('Generated SQL (Example 2 - Parameters):', params); // Expected: ['Electronics', 100] // Note: This library only builds SQL strings; it does not connect to or execute queries against a database. // You would typically pass these generated SQL strings and parameters to an actual database driver (e.g., 'mysql2' or 'pg'). // Example: Illustrating an intended (but potentially unimplemented/buggy) ORM-like interaction /* const { ORM } = require('database-utils'); const MyModel = new ORM('my_table'); async function runOrmExample() { try { // Assuming a 'find' method would exist, but this is highly speculative const data = await MyModel.find({ id: 1 }); console.log('\nORM-like find result:', data); // Or perhaps a 'create' method const newRecord = await MyModel.create({ name: 'Test', value: 123 }); console.log('ORM-like create result:', newRecord); } catch (error) { console.error('\nError during ORM-like operation:', error.message); } } runOrmExample(); */
Debug
Known issues
breakingThis project is explicitly marked as 'DEPRECATED' and 'not maintained' by its author on GitHub. It does not receive updates, bug fixes, or security patches, making it unsuitable for production use.
fix
Migrate to an actively maintained SQL builder or ORM library (e.g., Knex.js, Sequelize, TypeORM, Prisma) to ensure security, stability, and compatibility with modern Node.js and database systems.
affects: >=1.0.0
gotchaThe `README` lists a substantial 'TODO' section, indicating many planned features (e.g., `notlike`, `replace`, `having`, `between`, `limit in update()`, `ORM`) were never implemented or completed. Relying on advertised features might lead to missing functionality or unexpected behavior.
fix
Thoroughly review the source code for implemented features or assume that any feature not explicitly demonstrated in the limited examples is likely unfinished or buggy. Prefer alternative, well-documented libraries.
affects: >=1.0.0
gotchaThe library's age (last updated over 10 years ago) means it likely has significant compatibility issues with modern Node.js runtimes (e.g., ES modules, async/await patterns, newer buffer APIs) and contemporary database drivers/standards.
fix
Avoid using this library in new projects. If encountering it in legacy code, extreme caution and extensive testing are required for any upgrades or changes to the Node.js environment or database systems. Migration is strongly recommended.
affects: >=1.0.0
gotchaThe primary `SqlDriver` example for generating SQL is based on concatenation, which historically can be prone to SQL injection vulnerabilities if not handled meticulously. While `getQuerySql()` attempts to provide parameterized queries, the overall architecture might not enforce modern best practices for preventing such attacks.
fix
Always use a database driver's native parameterized query features with prepared statements. If forced to use this library, meticulously sanitize all user inputs and never directly concatenate untrusted data into SQL strings. However, the safest fix is to switch to a modern, actively maintained library designed with security in mind.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: SqlDriver is not a constructor
Attempting to import `SqlDriver` using ES module syntax (`import { SqlDriver } from 'database-utils';`) when the package only supports CommonJS `require`.
fix
Use CommonJS `require` syntax: `const { SqlDriver } = require('database-utils');`
UnhandledPromiseRejectionWarning: DeprecationWarning: This project is not maintained.
Node.js runtime or another dependency is detecting usage of an old or deprecated module, specifically this `database-utils` package, and issuing a warning.
fix
This warning is inherent to using an abandoned package. The only true fix is to replace `database-utils` with an actively maintained library. You might be able to suppress `DeprecationWarning` in Node.js, but this is highly discouraged as it hides critical information.
Error: Column 'some_field' cannot be used with LIKE operator in query builder.
Attempting to use advanced SQL operators like `like`, `notlike`, `between`, or `having` which are listed in the `TODO` section of the `README` but were likely never implemented.
fix
The feature is missing. You cannot use it with this library. You would need to manually write the raw SQL query or, preferably, migrate to a more robust SQL builder or ORM that supports these operators.
Upgrade
Version history
1.4.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
database-utils — npm install database-utils · libregistry