Registry / database / node-mysql-promise

node-mysql-promise

JSON →
library0.0.7jsnpmunverified

A lightweight promise-based MySQL model wrapper for Node.js, version 0.0.7. It provides a fluent query builder inspired by thinkjs, supporting table selection, fields, limits, pagination, unions, joins, and CRUD operations. Uses the mysql connection pool. Heavily outdated with minimal documentation; no longer actively maintained. Alternatives: mysql2/promise, knex.

npm install node-mysql-promise
INSTALL
IMPORT
SIG · NODE-MYSQL-PROMISE
N
node-mysql-promise
databasejavascriptv0.0.7
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
import Mysql from 'node-mysql-promise'
const { Mysql } = require('node-mysql-promise')
CommonJS require returns the constructor directly, not an object.
createConnection
import Mysql from 'node-mysql-promise'; const mysql = Mysql.createConnection({...})
const mysql = require('node-mysql-promise').createConnection({...})
createConnection is a static method on the default export.
table
import Mysql from 'node-mysql-promise'; const mysql = Mysql.createConnection({...}); mysql.table('table').select()
const mysql = require('node-mysql-promise')({...}); mysql.select()
table() must be called before query methods like select().

Shows basic SELECT, INSERT, UPDATE, DELETE operations using node-mysql-promise.

const Mysql = require('node-mysql-promise'); const mysql = Mysql.createConnection({ host: 'localhost', user: 'root', password: '', database: 'test' }); mysql.table('users').select() .then(rows => console.log(rows)) .catch(err => console.error(err)); // Insert example mysql.table('users').add({ name: 'John', age: 30 }) .then(result => console.log('Insert id:', result)) .catch(err => console.error(err)); // Update example mysql.table('users').where({ id: 1 }).update({ name: 'Jane' }) .then(affectedRows => console.log('Updated', affectedRows, 'rows')) .catch(err => console.error(err)); // Delete example mysql.table('users').where({ id: 1 }).delete() .then(affectedRows => console.log('Deleted', affectedRows, 'rows')) .catch(err => console.error(err));
Debug
Known issues
gotchaPackage is abandoned; last release in 2015, no updates for security or compatibility.
fix
Migrate to mysql2/promise or knex which are actively maintained.
affects: all
gotchaNo TypeScript definitions or type checking.
fix
Add custom .d.ts or use a type-safe alternative.
affects: all
gotchaError messages may be in Chinese, making debugging difficult for non-Chinese speakers.
fix
Wrap queries in try-catch and handle errors generically.
affects: all
gotchaRequires calling .table() before any query method; otherwise undefined table error.
fix
Always chain .table('tableName').select() etc.
affects: all
Errors
Common errors & fixes
Cannot find module 'node-mysql-promise'
Package not installed or name misspelled.
fix
Run: npm install node-mysql-promise
TypeError: mysql.table is not a function
Using the constructor directly instead of calling createConnection to get an instance.
fix
Correct usage: const mysql = Mysql.createConnection({...});
Upgrade
Version history
0.0.7latest on npm
Audit
Dependencies
mysqlrequiredUnderlying MySQL driver; bundled as a dependency
Agent activity
2 hits · last 30 days
node
2
Resources
node-mysql-promise — npm install node-mysql-promise · libregistry