Registry / database / fadab-mysql-helper

fadab-mysql-helper

JSON →
library1.4.2jsnpmunverified

Fadab MySQL Helper is a lightweight Promise-based wrapper for felixge's node-mysql library, providing convenience functions for selecting, inserting, updating, and upserting records with automatic connection pooling. Version 1.4.2 is the latest stable release, with a low update cadence. It requires a fadab.config.js or fadab.config.ts file in the project root for database configuration. Key differentiators include a very slim codebase with only two dependencies, support for advanced query building with where conditions, ordering, limits, and random selection, and full TypeScript support.

npm install fadab-mysql-helper
INSTALL
IMPORT
SIG · FADAB-MYSQL-HELPER
F
fadab-mysql-helper
databasejavascriptv1.4.2
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.

FadabMysql
import * as FadabMysql from 'fadab-mysql-helper';
import FadabMysql from 'fadab-mysql-helper';
This package exports a namespace object, not a default export. Use the namespace import for TypeScript.
selectAsync
FadabMysql.selectAsync('table', options);
selectAsync('table', options);
selectAsync is a method on the exported object, not a standalone function.
insertAsync
FadabMysql.insertAsync('table', data);
FadabMysql.insertAsync('table', data, callback);
All methods return Promises; callbacks are not supported.

Shows how to insert a record and then select it using the library's Promise-based methods.

const FadabMysql = require('fadab-mysql-helper'); async function example() { try { // Insert a record await FadabMysql.insertAsync('users', { name: 'John', email: 'john@example.com' }); // Select with where clause const users = await FadabMysql.selectAsync('users', { where: { email: 'john@example.com' }, limit: 1 }); console.log(users); } catch (err) { console.error('MySQL error:', err.message); } } example();
Debug
Known issues
breakingConfiguration file 'fadab.config.js' or 'fadab.config.ts' must exist in project root; otherwise, the library will throw an error.
fix
Create a fadab.config file with a 'mysql' property containing connection details.
affects: >=1.0.0
deprecatedThe dependency 'app-root-path' is used to locate the config file, which can cause issues in monorepo setups.
fix
Manually specify config path or use environment variables for connection.
affects: >=1.0.0
gotchaThe where clause in selectAsync uses a non-standard syntax: use 'eq', 'neq', 'gt', 'gte', 'lt', 'lte' for condition types.
fix
Refer to documentation for correct condition types (e.g., { key: 'age', value: 18, conditionType: 'gte' }).
affects: >=1.0.0
gotchaThe library does not support raw SQL queries; only high-level methods like selectAsync, insertAsync, updateAsync, etc.
fix
Use the underlying 'mysql' library directly if raw queries are needed.
affects: >=1.0.0
deprecatedThe 'mysql' package (felixge/node-mysql) is in maintenance mode; consider using 'mysql2' for better performance and features.
fix
Switch to a different MySQL helper that uses mysql2, or configure the library to use mysql2 (not officially supported).
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'fadab-mysql-helper'
Package not installed or not in node_modules.
fix
Run 'npm install fadab-mysql-helper --save'.
Error: Failed to load config file: fadab.config.js
Config file missing or malformed.
fix
Create fadab.config.js or fadab.config.ts in project root with valid MySQL connection options.
TypeError: FadabMysql.selectAsync is not a function
Incorrect import or destructuring.
fix
Use 'const FadabMysql = require('fadab-mysql-helper');' and call FadabMysql.selectAsync.
Error: ER_ACCESS_DENIED_ERROR: Access denied for user
Invalid MySQL credentials in fadab.config.
fix
Check host, user, password, and database in config file.
Error: connect ETIMEDOUT
MySQL server unreachable or firewall blocking.
fix
Verify MySQL host and port, ensure server is running and accessible.
Upgrade
Version history
1.4.2latest on npm
Audit
Dependencies
app-root-pathrequiredUsed to locate the fadab.config file from the project root.
mysqlrequiredUnderlying MySQL driver from felixge for database connectivity.
Agent activity
10 hits · last 30 days
node
8
Resources
fadab-mysql-helper — npm install fadab-mysql-helper · libregistry