Registry / database / mysql-adapter

mysql-adapter

JSON →
library0.0.7jsnpmunverified

A lightweight helper library for MySQL in Node.js, version 0.0.7, providing a simple wrapper around raw MySQL queries with convenience methods for common operations like select, insert, update, and joins. Released in early development with minimal release cadence. Differentiates from full ORMs like Sequelize by offering a thin, callback-based API that stays close to SQL. Latest version is 0.0.7, last updated several years ago.

npm install mysql-adapter
INSTALL
IMPORT
SIG · MYSQL-ADAPTER
M
mysql-adapter
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.

MySQL
import { MySQL } from 'mysql-adapter'
const mysql = require('mysql-adapter')
The package exports a named export 'MySQL' (class). CommonJS destructuring is also valid: const { MySQL } = require('mysql-adapter').
default import
import { MySQL } from 'mysql-adapter'
import MySQL from 'mysql-adapter'
There is no default export; only named export MySQL is available.
require
const { MySQL } = require('mysql-adapter')
const MySQL = require('mysql-adapter')
Simply requiring the package gives an object with the MySQL class. Assigning the whole require result to MySQL will not work.

Shows how to create a MySQL connection, connect, run a selectAll query with a WHERE clause, and close the connection.

const { MySQL } = require('mysql-adapter'); const conn = new MySQL({ host: 'localhost', user: 'root', password: 'password', database: 'test' }); conn.connect((err) => { if (err) { console.error(err); return; } conn.selectAll({ table: 'users', where: { active: 1 } }, (err, res) => { if (err) { console.error(err); return; } console.log(res); conn.close(); }); });
Debug
Known issues
gotchaThe package has not been updated since 2016 and relies on the older mysql package version that may have known vulnerabilities.
fix
Use an actively maintained MySQL library like mysql2 or an ORM like Sequelize.
affects: >=0.0.0
deprecatedThe insertOne method's 'where' parameter is used in the update example (it should be updateOne, but the API calls insertOne incorrectly).
fix
Use the intended updateOne method (if available) or use raw query for updates.
affects: >=0.0.0
gotchaAll queries use callbacks; Promises or async/await are not natively supported.
fix
Wrap methods in Promises or use a utility like util.promisify for async/await usage.
affects: >=0.0.0
gotchaThe join method requires specific property names and does not support LEFT JOIN, only RIGHT JOIN is shown; behavior may vary.
fix
Verify the joinType parameter supports both 'LEFT' and 'RIGHT'; test thoroughly.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'mysql-adapter'
Package is not installed or not in node_modules.
fix
npm install mysql-adapter
TypeError: MySQL is not a constructor
Importing the default export instead of named export.
fix
Use const { MySQL } = require('mysql-adapter');
Upgrade
Version history
0.0.7latest on npm
Audit
Dependencies
mysqlrequiredThe official MySQL driver for Node.js is required to establish connections and execute queries
Agent activity
5 hits · last 30 days
node
4
Resources
mysql-adapter — npm install mysql-adapter · libregistry