Qb is a JavaScript SQL query builder for Node.js that generates SQL from JSON objects instead of method chaining. Current stable version is 0.3.2. It builds on brianc/node-sql and supports PostgreSQL, MySQL, and SQLite. Key differentiator: designed for BI applications where non-technical users send JSON specifications via an API. It enforces security by only allowing defined tables/columns, supports automatic joins based on model associations, and provides context-aware aliases. The library is minimal and has no active releases since 2017, suggesting maintenance status.
npm install sql-query-builderNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to define tables, instantiate Qb, and generate a SELECT query with a WHERE clause.
npm install sql-query-builder sql --save
Always pass the dialect as second argument to the constructor, e.g. new Qb(definitions, 'mysql')
Use consistent casing in your definitions and spec field names, or override via aliases.
Ensure each table property has at least an empty object for its columns (e.g., 'id': {}).npm install sql
const Qb = require('sql-query-builder'); then new Qb(...)const qb = new Qb(definitions, 'postgres'); qb.query(spec);