Registry / database / uh-node-mysql-promise

uh-node-mysql-promise

JSON →
library0.0.10jsnpmunverified

A Promise-based MySQL query builder wrapper for Node.js using connection pooling from node-mysql. Version 0.0.10 provides a fluent API for SELECT, INSERT, UPDATE, DELETE with methods like table(), field(), limit(), page(), join(), union(), and where(). It simplifies raw SQL by chaining method calls and automatically escapes identifiers. Low release cadence (last update unknown). Differentiates from knex.js by being lighter and simpler, but lacks documentation on security and SQL injection; requires careful use. Not actively maintained.

npm install uh-node-mysql-promise
INSTALL
IMPORT
SIG · UH-NODE-MYSQL-PROM
U
uh-node-mysql-promise
databasejavascriptv0.0.10
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 Mysql = require('uh-node-mysql-promise');
import Mysql from 'uh-node-mysql-promise';
CJS-only package; ESM import will fail.
createConnection
const mysql = require('uh-node-mysql-promise').createConnection(options);
const mysql = new Mysql(...);
createConnection is a static method, not a constructor.
Mysql prototype methods
mysql.table('table').select().then(...).catch(...);
mysql.table('table').select().then(data => console.log(data)); // missing catch
Always handle promise rejections; unhandled rejections crash Node.

Demonstrates connecting to MySQL, chaining query builder methods, and handling promise result/error.

const Mysql = require('uh-node-mysql-promise'); const mysql = Mysql.createConnection({ host: 'localhost', user: 'root', password: process.env.DB_PASSWORD ?? '', database: 'test', tablePrefix: 'tbl_', charset: 'UTF8_GENERAL_CI', connectionLimit: 10 }); // SELECT with where, limit, and order mysql.table('user') .field(['id', 'name', 'email']) .where({ status: 1 }) .order('id DESC') .limit(5) .select() .then(rows => { console.log('Users:', rows); }) .catch(err => { console.error('Query failed:', err.message); });
Debug
Known issues
gotchaSQL injection risk if raw strings are passed to where(), order(), or having() instead of using parameterized objects.
fix
Always use object notation for where() conditions; avoid string concatenation with user input.
affects: >=0.0.0
breakingIf the mysql dependency version changes, the pool configuration might break due to deprecated options.
fix
Pin mysql dependency version in your package.json and test after updates.
affects: >=0.0.0
gotchaThe package does not export ESM; using import statements will throw 'ERR_REQUIRE_ESM'.
fix
Use require() instead of import, or use dynamic import() with .mjs extension.
affects: >=0.0.0
deprecatedThe field() method with string argument splits by comma but does NOT trim whitespace; extra spaces may cause unexpected column names.
fix
Use array notation for fields to avoid parsing issues.
affects: >=0.0.0
gotchaChaining multiple where() calls overwrites previous conditions instead of adding them.
fix
Pass all conditions as a single object to where() to combine them.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: mysql.table is not a function
createConnection was not called or wrong import.
fix
var mysql = Mysql.createConnection({...}); then mysql.table('table')
Can't set headers after they are sent
Multiple responses sent due to unhandled promise or missing return.
fix
Ensure .then() and .catch() handle exactly one response and use async/await correctly.
Error: ER_BAD_FIELD_ERROR: Unknown column 'X' in 'field list'
field() string includes whitespace around column names.
fix
Use array notation: .field(['col1', 'col2'])
Upgrade
Version history
0.0.10latest on npm
Audit
Dependencies
mysqlrequiredUses mysql package's connection pool internally
Agent activity
20 hits · last 30 days
node
16
OpenAI (training)
2
Meta
1
Resources
uh-node-mysql-promise — npm install uh-node-mysql-promise · libregistry