Registry / database / mysql-qbuilder

mysql-qbuilder

JSON →
library1.6.1jsnpmunverified

Query builder for MySQL databases in Node.js, providing a fluent interface for constructing SQL queries including SELECT, INSERT, UPDATE, DELETE, JOIN, WHERE conditions, ORDER BY, GROUP BY, LIMIT, and OFFSET. Current stable version is 1.6.1, last updated in 2018. Connects using the mysql module and protects against SQL injection. Key differentiators: simple API, supports chaining, and provides query model methods like add, getFirst, getLast, getAll, findById, findFields. However, the package appears unmaintained with no recent updates, and relies on outdated Node.js engine requirements (>= 6.0.0).

npm install mysql-qbuilder
INSTALL
IMPORT
SIG · MYSQL-QBUILDER
M
mysql-qbuilder
databasejavascriptv1.6.1
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
✓ const qBuilder = require('mysql-qbuilder')
✗ import qBuilder from 'mysql-qbuilder'
Package uses CommonJS and does not support ES module imports.
qBuilder.setOptions
✓ qBuilder.setOptions({ hostname: '...', username: '...', password: '...', database: '...' })
✗ qBuilder.setOptions({ host: '...', user: '...', pass: '...', db: '...' })
Options object uses specific keys (hostname, username, password, database). Misnaming keys causes silent failures.
qBuilder.makeQuery
✓ qBuilder.makeQuery().select('*').from('table')
✗ qBuilder.select('*').from('table')
makeQuery() must be called to start a new query chain; methods on qBuilder directly are not available.

Demonstrates setup with environment variables, connection, query building with select, from, where, orderBy, limit, and execution via prepare().getResult().

const qBuilder = require('mysql-qbuilder'); qBuilder.setOptions({ hostname: process.env.DB_HOST ?? 'localhost', username: process.env.DB_USER ?? 'root', password: process.env.DB_PASS ?? '', database: process.env.DB_NAME ?? 'test' }); qBuilder.connectToDatabase() .then(() => { return qBuilder.makeQuery() .select('id, name, email') .from('users') .where('age', '>', 18) .orderBy('name', 'ASC') .limit(10) .prepare() .getResult(); }) .then(results => { console.log('Users:', results); }) .catch(err => { console.error('Error:', err); });
Debug
Known issues
deprecatedNode.js engine requirement >= 6.0.0 is outdated; packages relying on newer Node.js features may fail.
fix
Use Node.js 10+ for compatibility; consider using a maintained query builder like knex.
affects: >=1.0.0
gotchaPackage has not been updated since 2018; known vulnerabilities in mysql dependency may exist.
fix
Audit dependencies or switch to a maintained alternative. Use npm audit to check for issues.
affects: <=1.6.1
gotchaqBuilder.setOptions uses property names hostname, username, password, database; not standard mysql connection host, user, password, database.
fix
Use the exact option keys as shown in the documentation: hostname, username, password, database.
affects: >=1.0.0
breakingIn version 1.5.1+, getResult() changed from synchronous to promise-based (via prepare()).
fix
Use .prepare().getResult().then(...) or await qBuilder.prepare().getResult() instead of calling getResult() directly.
affects: >=1.5.1
gotchaMethods like addSelect, where, and join modify the internal query state; chaining order matters.
fix
Ensure clauses are called in the correct order (e.g., select before from, where before orderBy).
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: qBuilder.makeQuery(...).prepare is not a function
Using version <1.5.1 where prepare() did not exist; getResult() was synchronous.
fix
Update to version >=1.5.1 or if using older version, call .getResult() directly without .prepare().
Cannot read property 'hostname' of undefined
setOptions was not called before connectToDatabase, or options object is empty.
fix
Call qBuilder.setOptions({...}) with appropriate connection details before connecting.
Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'user'@'host' (using password: YES)
Invalid credentials or missing database connection parameters.
fix
Verify hostname, username, password, and database in setOptions. Ensure MySQL server is running.
TypeError: qBuilder.makeQuery is not a function
Package not properly required or imported incorrectly.
fix
Use const qBuilder = require('mysql-qbuilder') and ensure the module is installed.
Upgrade
Version history
1.6.1latest on npm
Audit
Dependencies
mysqlrequiredPeer dependency for MySQL connection and query execution.
Agent activity
7 hits · last 30 days
node
6
Resources
mysql-qbuilder — npm install mysql-qbuilder · libregistry