Registry / database / eq-mysql

eq-mysql

JSON →
library1.1.5jsnpmunverified

A lightweight Node.js MySQL query builder wrapper around the `mysql` package, designed to simplify common database operations like select, insert, update, delete, and joins. Version 1.1.5 is the latest stable release, with no active development observed. It provides a chainable API for building SQL queries (select, where, orderBy, groupBy, join, etc.) and supports promise-based async/await. Key differentiators include automatic SQL injection protection via parameterized queries, multiple where clause formats (string, object, array), and a `create` method for multiple database instances. However, it lacks TypeScript support, connection pooling documentation, and may have maintenance concerns.

npm install eq-mysql
INSTALL
IMPORT
SIG · EQ-MYSQL
E
eq-mysql
databasejavascriptv1.1.5
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 eqMysql = require('eq-mysql');
const eqMysql = require('eq-mysql').default;
CommonJS module; no default export in ESM.
config
eqMysql.config({...});
const { config } = require('eq-mysql');
config is a method on the root object, not a named export.
table
const { table } = eqMysql;
const { table } = require('eq-mysql');
table is a method on the root object; destructuring works after require.

Shows how to configure eq-mysql with environment variables, then use the chainable builder to fetch active users.

const eqMysql = require('eq-mysql'); eqMysql.config({ host: process.env.DB_HOST ?? 'localhost', database: process.env.DB_NAME ?? 'test', user: process.env.DB_USER ?? 'root', password: process.env.DB_PASS ?? '', port: 3306 }); const { table, query } = eqMysql; // Create a table reference and perform a query async function getActiveUsers() { const rows = await table('users') .select('id, name, email') .where({ status: 'active' }) .orderBy('created_at desc') .all(); console.log(rows); } getActiveUsers().catch(console.error);
Debug
Known issues
gotchaThe 'mysql' package is a dependency, not 'mysql2'. 'mysql' may have performance issues with unsigned integers and is generally slower than 'mysql2'.
fix
Consider using a wrapper that supports 'mysql2' or manually replace the dependency.
affects: >=1.0.0
deprecatedThe 'config' method sets a global configuration; subsequent calls overwrite it. This can cause issues in multi-tenant applications.
fix
Use eqMysql.create({...}) for separate instances instead of config().
affects: >=1.0.0
breakingNo connection pool is created by default; each query creates a new connection if not configured manually.
fix
Implement a custom pool using the underlying 'mysql' package and pass the pool's connection via config().
affects: >=1.0.0
gotchaThe 'where' object syntax treats values of type Array as IN clauses, not OR. { id: [1,2] } becomes 'id IN (1,2)'.
fix
Use array-of-arrays syntax for OR conditions: where([['id', '=', 1], ['id', '=', 2]])
affects: >=1.0.0
deprecatedThe package uses the deprecated 'mysql' package's callback API internally; no async/await support at the driver level.
fix
Consider migrating to a more modern library like 'mysql2' with built-in promise support.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'mysql'
eq-mysql requires mysql as a peer dependency but it may not be installed.
fix
Run npm install mysql
TypeError: eqMysql.config is not a function
Incorrect import or the package is not loaded properly.
fix
Ensure you are requiring eq-mysql with const eqMysql = require('eq-mysql');
Error: ER_ACCESS_DENIED_ERROR: Access denied for user '...'
Incorrect database credentials or host not accessible.
fix
Verify host, user, password, and database in the config.
Upgrade
Version history
1.1.5latest on npm
Audit
Dependencies
mysqlrequiredUnderlying MySQL driver for database connection and queries.
Agent activity
6 hits · last 30 days
node
6
Resources
eq-mysql — npm install eq-mysql · libregistry