Registry / database / dabs
library0.0.32jsnpmunverified

dabs is a MySQL query builder that wraps MySQL2 to provide a fluent API for constructing SQL queries (SELECT, INSERT, UPDATE, DELETE) with support for joins, aggregations, parameterized placeholders, and computed fields. Current version 0.0.32 is pre-1.0 with no fixed release cadence. Differentiates with a chainable syntax using field references via table aliases, automatic identifier quoting, and inline parameter binding via db._() placeholders. However, it is very early-stage, lacks comprehensive documentation, and may have breaking changes. Alternative libraries like knex or squel are more mature.

npm install dabs
INSTALL
IMPORT
SIG · DABS
D
dabs
databasejavascriptv0.0.32
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 (dabs)
✓ const dabs = require('dabs')
✗ import dabs from 'dabs' (not ESM-compatible; package uses CJS)
Package is CommonJS-only (no module entry in package.json). Use require().
connect
✓ const db = await dabs.connect('mysql://user:pass@host/database')
✗ dabs.connect(callback) (must use async/await or .then())
connect() returns a Promise. Do not call it synchronously.
table
✓ const u = db.table('users')
✗ const u = dabs.table('users') (table is a method on a connected database instance, not on the top-level import)
First call connect() to get db, then use db.table() to create a table reference.
fn (functions)
✓ db.fn.COUNT(n.id).as('alias_count')
✗ db.fn['COUNT'](n.id) (works but not idiomatic)
db.fn exposes SQL aggregate functions like COUNT, AVG, SUM, MIN, MAX. Use as method to alias.

Connects to MySQL using a URL, builds a SELECT query with a parameterized WHERE clause, executes with bound parameters, and logs the result.

const dabs = require('dabs'); (async () => { const db = await dabs.connect(process.env.DB_URL ?? 'mysql://user:pass@localhost/mydb'); const u = db.table('users'); const q = u.select(u.name, u.email) .where(u.id.equals(db._('uid'))) .sortBy(u.name.asc()); const result = await q.exec({ uid: 1 }); console.log(result); await db.close(); })();
Debug
Known issues
gotchaVersion 0.0.32 is pre-1.0, breaking changes may occur without major version bumps.
fix
Pin exact version in package.json and review changelog after updates.
affects: >=0.0.0
gotchaPackage uses CommonJS require() only; attempting ESM import will fail.
fix
Use require('dabs') or use dynamic import() in ESM projects.
affects: >=0.0.0
gotchaThe connect() method returns a Promise; calling it synchronously will yield undefined.
fix
Use await or .then().
affects: >=0.0.0
gotchaPlaceholders are specified via db._('name') in queries but must be bound as an object in exec({name: value}). Name mismatch causes silent errors or SQL errors.
fix
Ensure placeholder names match exactly between db._('name') and exec({name: ...}).
affects: >=0.0.0
gotchatable() returns a reference that uses backtick quoting; column names passed as strings (e.g., 'users.name') are not automatically qualified.
fix
Always use table column methods (u.name) rather than raw strings for proper quoting and aliasing.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: dabs.connect is not a function
CommonJS import failed because package is not installed or used with require.
fix
Run 'npm install dabs' and use 'const dabs = require('dabs');'
Cannot read property 'table' of undefined
connect() was called without await, so db is undefined.
fix
Use await dabs.connect(...) or handle promise with .then(db => ...)
ER_BAD_FIELD_ERROR: Unknown column 'x' in 'field list'
Column placeholder name mismatch between db._('name') and exec({name: value}) or misspelled field.
fix
Verify placeholder name in query matches key in bind object.
Upgrade
Version history
0.0.32latest on npm
Audit
Dependencies
mysql2requiredCore database driver for MySQL connections and query execution
Agent activity
15 hits · last 30 days
node
12
OpenAI (training)
1
Resources
packagedabs ↗
dabs — npm install dabs · libregistry