Registry / database / mq-node

mq-node

JSON →
library1.0.11jsnpmunverified

A MySQL query builder library for Node.js, inspired by mQ.php, that allows constructing INSERT, SELECT, UPDATE, and DELETE queries using JSON objects. It wraps the node-mysql (mysql) driver for connection and execution. Stable version 1.0.11, no frequent updates; last release in 2014. Differentiator: extremely simple JSON-based query construction without ORM overhead. Minimal dependencies, relies on the deprecated 'mysql' package.

npm install mq-node
INSTALL
IMPORT
SIG · MQ-NODE
M
mq-node
databasejavascriptv1.0.11
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.

mq
const mq = require('mq-node')({ host: 'localhost', user: 'root', password: '', database: 'test' });
const mq = require('mq-node');
The module exports a function that must be called with connection config; it returns the query builder instance.
insert
mq.insert('table', { col: 'val' }, callback);
mq.insert('table', { col: 'val' });
Callback is optional but needed to get results. No promise support.
select
mq.select({ from: 'table', where: { id: 1 } }, callback);
mq.select('table', { where: { id: 1 } }, callback);
First argument must be an object with properties like 'from', 'where', etc. Not a table name.

Demonstrates basic INSERT, SELECT, UPDATE, DELETE using JSON query objects with callbacks.

const mq = require('mq-node')({ host : 'localhost', user : 'root', password : '', database : 'test' }); // Insert mq.insert('users', { name: 'John', age: 30 }, function(err, result) { if (err) throw err; console.log('Inserted ID:', result.insertId); }); // Select mq.select({ from: 'users', where: { name: 'John' }, cols: ['name', 'age'] }, function(err, rows) { if (err) throw err; console.log('Rows:', rows); }); // Update mq.update('users', { age: 31 }, { name: 'John' }, function(err, result) { if (err) throw err; console.log('Updated rows:', result.affectedRows); }); // Delete mq.delete('users', { name: 'John' }, function(err, result) { if (err) throw err; console.log('Deleted rows:', result.affectedRows); });
Debug
Known issues
deprecatedDependency 'mysql' is deprecated; consider using 'mysql2'.
fix
Replace 'mysql' with 'mysql2' and update code to use promise-based API if desired.
affects: >=0.0.0
gotchamq() must be called with connection config; otherwise it returns undefined.
fix
Always call require('mq-node')(config) to get the query builder instance.
affects: >=0.0.0
gotchaLibrary does not support promises; all operations use callbacks.
fix
Wrap with util.promisify or use a promise wrapper.
affects: >=0.0.0
deprecatedNo updates since 2014; unmaintained.
fix
Consider migrating to 'knex', 'mysql2', or a modern query builder.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot read property 'query' of undefined
require('mq-node') returns a function, not the query builder, if not called with config.
fix
const mq = require('mq-node')(config); then use mq.query(...)
TypeError: callback is not a function
Select/insert/update/delete called without a callback function.
fix
Always provide a callback: mq.select({...}, function(err, res) {...});
ER_PARSE_ERROR: You have an error in your SQL syntax
Invalid JSON structure passed to query builders (e.g., missing 'from' property).
fix
Ensure the object passed to select/insert/update/delete has correct keys.
Upgrade
Version history
1.0.11latest on npm
Audit
Dependencies
mysqlrequiredUses 'mysql' as the underlying MySQL client for connections and query execution.
Agent activity
2 hits · last 30 days
node
2
Resources
mq-node — npm install mq-node · libregistry