{"id":42577,"library":"dabs","title":"dabs","description":"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.","status":"active","version":"0.0.32","language":"javascript","source_language":"en","source_url":null,"tags":["javascript"],"install":[{"cmd":"npm install dabs","lang":"bash","label":"npm"},{"cmd":"yarn add dabs","lang":"bash","label":"yarn"},{"cmd":"pnpm add dabs","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core database driver for MySQL connections and query execution","package":"mysql2","optional":false}],"imports":[{"note":"Package is CommonJS-only (no module entry in package.json). Use require().","wrong":"import dabs from 'dabs' (not ESM-compatible; package uses CJS)","symbol":"default (dabs)","correct":"const dabs = require('dabs')"},{"note":"connect() returns a Promise. Do not call it synchronously.","wrong":"dabs.connect(callback) (must use async/await or .then())","symbol":"connect","correct":"const db = await dabs.connect('mysql://user:pass@host/database')"},{"note":"First call connect() to get db, then use db.table() to create a table reference.","wrong":"const u = dabs.table('users') (table is a method on a connected database instance, not on the top-level import)","symbol":"table","correct":"const u = db.table('users')"},{"note":"db.fn exposes SQL aggregate functions like COUNT, AVG, SUM, MIN, MAX. Use as method to alias.","wrong":"db.fn['COUNT'](n.id) (works but not idiomatic)","symbol":"fn (functions)","correct":"db.fn.COUNT(n.id).as('alias_count')"}],"quickstart":{"code":"const dabs = require('dabs');\n(async () => {\n  const db = await dabs.connect(process.env.DB_URL ?? 'mysql://user:pass@localhost/mydb');\n  const u = db.table('users');\n  const q = u.select(u.name, u.email)\n    .where(u.id.equals(db._('uid')))\n    .sortBy(u.name.asc());\n  const result = await q.exec({ uid: 1 });\n  console.log(result);\n  await db.close();\n})();","lang":"javascript","description":"Connects to MySQL using a URL, builds a SELECT query with a parameterized WHERE clause, executes with bound parameters, and logs the result."},"warnings":[{"fix":"Pin exact version in package.json and review changelog after updates.","message":"Version 0.0.32 is pre-1.0, breaking changes may occur without major version bumps.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use require('dabs') or use dynamic import() in ESM projects.","message":"Package uses CommonJS require() only; attempting ESM import will fail.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use await or .then().","message":"The connect() method returns a Promise; calling it synchronously will yield undefined.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Ensure placeholder names match exactly between db._('name') and exec({name: ...}).","message":"Placeholders 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.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Always use table column methods (u.name) rather than raw strings for proper quoting and aliasing.","message":"table() returns a reference that uses backtick quoting; column names passed as strings (e.g., 'users.name') are not automatically qualified.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'-1.0':39 '0.0.32':36 'aggreg':28 'alias':55 'altern':81 'api':15 'automat':56 'bind':62 'break':79 'builder':7 'cadenc':44 'chainabl':48 'chang':80 'comprehens':74 'comput':32 'construct':17 'current':34 'dab':1,2 'db._':64 'delet':23 'differenti':45 'document':75 'earli':71 'early-stag':70 'field':33,51 'fix':42 'fluent':14 'howev':66 'identifi':57 'inlin':60 'insert':21 'javascript':90 'join':27 'knex':84 'lack':73 'librari':82 'like':83 'matur':89 'may':77 'mysql':5 'mysql2':10 'paramet':61 'parameter':29 'placehold':30,65 'pre':38 'provid':12 'queri':6,19 'quot':58 'refer':52 'releas':43 'select':20 'sql':18 'squel':86 'stage':72 'support':25 'syntax':49 'tabl':54 'updat':22 'use':50 'version':35 'via':53,63 'wrap':9","created_at":"2026-06-05T16:55:39.761290+00:00","updated_at":"2026-06-05T16:55:39.761290+00:00","problems":[{"fix":"Run 'npm install dabs' and use 'const dabs = require('dabs');'","cause":"CommonJS import failed because package is not installed or used with require.","error":"TypeError: dabs.connect is not a function"},{"fix":"Use await dabs.connect(...) or handle promise with .then(db => ...)","cause":"connect() was called without await, so db is undefined.","error":"Cannot read property 'table' of undefined"},{"fix":"Verify placeholder name in query matches key in bind object.","cause":"Column placeholder name mismatch between db._('name') and exec({name: value}) or misspelled field.","error":"ER_BAD_FIELD_ERROR: Unknown column 'x' in 'field list'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://www.intellix.eu","github":null,"docs":null,"changelog":null,"pypi":null,"npm":"dabs","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}