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.

database
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.

CommonJS module; no default export in ESM.

const eqMysql = require('eq-mysql');

config is a method on the root object, not a named export.

eqMysql.config({...});

table is a method on the root object; destructuring works after require.

const { table } = eqMysql;

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 footguns
gotchaThe 'mysql' package is a dependency, not 'mysql2'. 'mysql' may have performance issues with unsigned integers and is generally slower than 'mysql2'.
deprecatedThe 'config' method sets a global configuration; subsequent calls overwrite it. This can cause issues in multi-tenant applications.
breakingNo connection pool is created by default; each query creates a new connection if not configured manually.
gotchaThe 'where' object syntax treats values of type Array as IN clauses, not OR. { id: [1,2] } becomes 'id IN (1,2)'.
deprecatedThe package uses the deprecated 'mysql' package's callback API internally; no async/await support at the driver level.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
8 hits · last 30 days
gptbot
3
mj12bot
2
Resources