{"id":42619,"library":"dbqb","title":"DBQB — MySQL Query Builder","description":"DBQB v1.0.50 is a lightweight, TypeScript-first MySQL query builder for Node.js that generates parameterized SQL queries (SELECT, INSERT, UPDATE, DELETE, COUNT) using a simple JSON syntax. It supports complex WHERE/Having conditions including operators (>, <, BETWEEN, LIKE, IN, IS NULL), OR/AND nesting via Symbol('OR'), and raw string conditions. Unlike full ORMs like Sequelize or Knex, DBQB focuses solely on query generation without executing queries — you provide getTables/getFields callbacks. Released weekly on npm with TypeScript definitions. Current stable version: 1.0.50. Peer dependency: sequelize ^6.28.0 (only for type compatibility, not runtime).","status":"active","version":"1.0.50","language":"javascript","source_language":"en","source_url":"https://github.com/i31pc17/dbqb","tags":["javascript","mysql","query builder","nodejs","database","db","typescript"],"install":[{"cmd":"npm install dbqb","lang":"bash","label":"npm"},{"cmd":"yarn add dbqb","lang":"bash","label":"yarn"},{"cmd":"pnpm add dbqb","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required for TypeScript type compatibility (e.g., IFieldItem types). Not used at runtime for query generation.","package":"sequelize","optional":true}],"imports":[{"note":"Default export only. Named import will cause undefined error.","wrong":"import { DBQB } from 'dbqb'","symbol":"DBQB","correct":"import DBQB from 'dbqb'"},{"note":"Type import only available in TypeScript. Runtime use will throw.","wrong":"import { IFieldItem } from 'dbqb'","symbol":"IFieldItem","correct":"import type { IFieldItem } from 'dbqb'"},{"note":"CommonJS require gets the default export. Destructuring from require will fail because the module does not export named members.","wrong":"const { DBQB } = require('dbqb')","symbol":"DBQB","correct":"const DBQB = require('dbqb')"}],"quickstart":{"code":"import DBQB from 'dbqb';\n\nconst dbqb = new DBQB({\n  getTables: () => ['user', 'order'],\n  getFields: (table: string) => [\n    { Field: 'id', Type: 'int', Null: 'NO', Key: 'PRI', Default: '', Extra: 'auto_increment' },\n    { Field: 'nick', Type: 'varchar(32)', Null: 'NO', Key: '', Default: '', Extra: '' }\n  ]\n});\n\nasync function example() {\n  const query = await dbqb.selectQuery({\n    table: 'user',\n    where: { id: 'test' }\n  });\n  console.log(query); // SELECT * FROM `user` WHERE id = 'test';\n}\n\nexample();","lang":"typescript","description":"Initializes DBQB with table/field introspection callbacks and generates a simple SELECT query."},"warnings":[{"fix":"Always provide both callback functions when instantiating DBQB.","message":"DBQB constructor requires getTables and getFields callbacks; omitting them throws a runtime error.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Define the symbols once: const OR = Symbol('OR'); const AND = Symbol('AND'); and reuse them.","message":"Using Symbol('OR') or Symbol('AND') in where conditions requires const OR = Symbol('OR') but the library only checks the symbol key. Using a literal Symbol('OR') each time creates a new symbol, but DBQB uses the same symbol instance internally; you must use the same symbol reference.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use a plain object literal for 'set', e.g., set: { nick: 'new' }.","message":"The 'set' property name in updateQuery and insertUpdateQuery conflicts with JavaScript's Set object. Ensure you use a plain object, not a Set instance.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade to v1.0.0+ and await all query methods.","message":"Query methods return a string, not a promise in older versions; async/await is required since v1.0.0.","severity":"deprecated","affected_versions":"<1.0.0"},{"fix":"Ensure your callback returns objects matching the IFieldItem interface exactly.","message":"The getFields callback must return an array of IFieldItem objects with exact fields: Field, Type, Null, Key, Default, Extra. Missing or extra fields will cause unexpected behavior.","severity":"breaking","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.0.50':84 '6.28.0':88 'builder':4,15,98 'callback':73 'compat':92 'complex':35 'condit':37,53 'count':27 'current':81 'databas':100 'db':101 'dbqb':1,5,61 'definit':80 'delet':26 'depend':86 'execut':68 'first':12 'focus':62 'full':55 'generat':19,66 'gettables/getfields':72 'includ':38 'insert':24 'javascript':95 'json':31 'knex':60 'lightweight':9 'like':41,57 'mysql':2,13,96 'nest':46 'node.js':17 'nodej':99 'npm':77 'null':44 'oper':39 'or/and':45 'orm':56 'parameter':20 'peer':85 'provid':71 'queri':3,14,22,65,69,97 'raw':51 'releas':74 'runtim':94 'select':23 'sequel':58,87 'simpl':30 'sole':63 'sql':21 'stabl':82 'string':52 'support':34 'symbol':48 'syntax':32 'type':91 'typescript':11,79,102 'typescript-first':10 'unlik':54 'updat':25 'use':28 'v1.0.50':6 'version':83 'via':47 'week':75 'where/having':36 'without':67","created_at":"2026-06-05T16:55:51.243213+00:00","updated_at":"2026-06-05T16:55:51.243213+00:00","problems":[{"fix":"Change to: import DBQB from 'dbqb'","cause":"Using named import instead of default import: import { DBQB } from 'dbqb'","error":"TypeError: DBQB is not a constructor"},{"fix":"Install sequelize: npm install sequelize. Ensure tsconfig.json has 'moduleResolution': 'node' and 'esModuleInterop': true.","cause":"Missing sequelize peer dependency or incorrect TypeScript configuration (e.g., no moduleResolution: 'node').","error":"Cannot find module 'dbqb' or its corresponding type declarations."},{"fix":"Use a constant: const OR = Symbol('OR'); then use [OR]: {...}","cause":"Using Symbol('OR') in TypeScript without declaring a symbol constant; TypeScript errors because Symbol('OR') is not a valid property name.","error":"Property 'Symbol' does not exist on type ..."}],"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://github.com/i31pc17/dbqb","github":"https://github.com/i31pc17/dbqb","docs":null,"changelog":null,"pypi":null,"npm":"dbqb","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}}