Registry / database / mysql-helper-es6

mysql-helper-es6

JSON →
library0.2.1jsnpmunverified

A lightweight MySQL helper library using async/await syntax (ES2017) for Node.js. Version 0.2.1 provides a singleton-based wrapper around the mysql package with methods for select, selectOne, insertInto, batchInsertInto, replaceInto, update, and delete. It supports simple and range WHERE conditions. Designed for Node.js v8+, it is a minimal alternative to more full-featured ORMs like Sequelize or TypeORM. No TypeScript types included; for TS support, see ts-mysql-helper.

npm install mysql-helper-es6
INSTALL
IMPORT
SIG · MYSQL-HELPER-ES6
M
mysql-helper-es6
databasejavascriptv0.2.1
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 MysqlHelper = require('mysql-helper-es6')
import MysqlHelper from 'mysql-helper-es6'
Package does not provide ES module exports; use CommonJS require().
getInstance
MysqlHelper.getInstance(config)
new MysqlHelper(config)
getInstance is a static factory method returning a singleton instance. Do not use 'new'.
select
await helper.select(table, fields, where, limit)
helper.select(table, fields, where, limit).then(...)
Methods return Promises, so both async/await and .then() work; no callback style.

Initialize the MySQL helper with connection config and perform a simple select query using async/await.

const MysqlHelper = require('mysql-helper-es6'); const config = { host: 'localhost', port: 3306, database: 'mydb', user: 'root', password: process.env.DB_PASSWORD ?? '' }; const helper = MysqlHelper.getInstance(config); (async () => { try { const rows = await helper.select('users', ['name', 'email'], { id: 1 }, 1); console.log(rows); } catch (err) { console.error(err); } })();
Debug
Known issues
deprecatedPackage is not actively maintained; last update was years ago. Newer alternatives like mysql2 or knex are recommended.
fix
Consider migrating to mysql2 with promise wrapper, or use an ORM like Sequelize.
affects: *
gotchaSingleton pattern: getInstance returns the same instance for the same config, but calling getInstance with different config does not create a new connection pool; it reuses the first one.
fix
If you need multiple connections, avoid using the singleton; instead manage separate instances manually.
affects: *
gotchaNo built-in connection pool configuration; relies on underlying mysql package's default pool settings which may not suit production loads.
fix
Use mysql2 or another driver that exposes pool options, or wrap the library with custom pool management.
affects: *
gotchaThe where clause supports operators like '>=', '<' inside objects, but the format is non-standard and may cause confusion for complex queries.
fix
Refer to README for supported operators; for complex queries, consider writing raw SQL.
affects: *
Errors
Common errors & fixes
TypeError: MysqlHelper.getInstance is not a function
Using ES module import syntax (import) instead of CommonJS require.
fix
Use const MysqlHelper = require('mysql-helper-es6');
Error: Cannot find module 'mysql-helper-es6'
Package not installed or import path incorrect.
fix
Run npm install mysql-helper-es6 and ensure you are not using a relative path incorrectly.
Error: getInstance(...) returns undefined
Forgetting to pass config object to getInstance, or config is malformed.
fix
Ensure you call MysqlHelper.getInstance({host, user, password, database...}); config must have required fields.
Upgrade
Version history
0.2.1latest on npm
Audit
Dependencies
mysqlrequiredRequired for MySQL database connections and queries.
Agent activity
2 hits · last 30 days
node
2
Resources
mysql-helper-es6 — npm install mysql-helper-es6 · libregistry