Registry / database / mysql-nodejs

mysql-nodejs

JSON →
library1.6.0jsnpmunverified

A promise-based wrapper for the mysql npm package that simplifies building SQL queries. Current version 1.6.0 provides a fluent query builder with methods like find, insert, update, and delete. Released as needed with moderate cadence. Differentiator: lightweight alternative to Sequelize/TypeORM with promise-based API and automatic connection management. Compatible with mysql package. Not actively maintained (last update 2019).

npm install mysql-nodejs
INSTALL
IMPORT
SIG · MYSQL-NODEJS
M
mysql-nodejs
databasejavascriptv1.6.0
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.

Mysql
const Mysql = require('mysql-nodejs')
import Mysql from 'mysql-nodejs'
Package does not ship ESM; CommonJS only. Use require().
model
Mysql.model('tablename')
new Mysql.Model('tablename')
Mysql.model() is a static method, not a constructor.
connection
Mysql.connection.on('connected', ...)
Mysql.connect().connection.on(...)
connection is set synchronously after connect(), not returned as promise.

Connects to MySQL, defines a model for 'users' table, and fetches rows where age > 18.

const Mysql = require('mysql-nodejs'); const { MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE } = process.env; Mysql.connect({ host: MYSQL_HOST ?? 'localhost', user: MYSQL_USER ?? 'root', password: MYSQL_PASSWORD ?? '', database: MYSQL_DATABASE ?? 'test' }); const User = Mysql.model('users'); User.find({ age: { '>': 18 } }) .exec() .then(rows => console.log(rows)) .catch(err => console.error(err));
Debug
Known issues
gotchaPackage only supports CommonJS require(). Does not export ESM modules.
fix
Use require('mysql-nodejs') in Node.js projects; cannot import in browser.
affects: >=1.0
gotchaMysql.connect() must be called before using Mysql.model() or any queries.
fix
Call connect() at application startup, before any model operations.
affects: >=1.0
breakingThe mysql package (peer dependency) changed API; ensure compatible version (>=2.18).
fix
Install mysql@2.18.1 or later in your project.
affects: >=1.0
deprecatedPackage last updated in 2019. No longer actively maintained.
fix
Consider migrating to mysql2 or Sequelize for ongoing support.
affects: >=1.0
Errors
Common errors & fixes
Error: Mysql is not defined
Missing require('mysql-nodejs') at top of file.
fix
Add const Mysql = require('mysql-nodejs');
Cannot read property 'model' of undefined
Mysql.connect() not called or failed without error handling.
fix
Call Mysql.connect(options) before Mysql.model().
TypeError: Mysql.connect(...) is not a function
Incorrect import (e.g., using ESM import statement).
fix
Use require('mysql-nodejs') instead of import.
Upgrade
Version history
1.6.0latest on npm
Audit
Dependencies
mysqlrequiredUnderlying MySQL driver that communicates with the database.
Agent activity
2 hits · last 30 days
node
2
Resources
mysql-nodejs — npm install mysql-nodejs · libregistry