Registry / database / meadow-connection-mysql

meadow-connection-mysql

JSON →
library1.0.19jsnpmunverified

A MySQL connection pool provider for the Meadow ORM, wrapping mysql2 as a Fable service. Current stable version 1.0.19. Provides connection pooling with named placeholders, auto-connect support, and DDL generation from Meadow table schemas. Supports both Meadow-style and mysql2-native configuration formats. Notable differentiator: integrates tightly with the Fable dependency injection framework, offering auto-connect guards and schema-driven table creation. Release cadence is irregular; last release November 2023.

npm install meadow-connection-mysql
INSTALL
IMPORT
SIG · MEADOW-CONNECTION-
M
meadow-connection-mysql
databasejavascriptv1.0.19
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.

MeadowConnectionMySQL
const MeadowConnectionMySQL = require('meadow-connection-mysql');
import MeadowConnectionMySQL from 'meadow-connection-mysql';
Package uses CommonJS; there is no ESM export. Using import will result in a default import error.
libFable
const libFable = require('fable');
import libFable from 'fable';
Fable is also CommonJS. ESM import will fail.
MeadowConnectionMySQL.pool
const pool = fable.MeadowMySQLProvider.pool;
const pool = MeadowConnectionMySQL.pool;
The pool instance is accessible only after registering the service with a Fable instance via serviceManager.addAndInstantiateServiceType.

Initializes a Fable instance with MySQL config, adds MeadowConnectionMySQL as a service, auto-connects, and runs a test query.

const libFable = require('fable'); const MeadowConnectionMySQL = require('meadow-connection-mysql'); let fable = new libFable({ MySQL: { Server: '127.0.0.1', Port: 3306, User: 'root', Password: process.env.MYSQL_PASSWORD ?? '', Database: 'my_app', ConnectionPoolLimit: 20 }, MeadowConnectionMySQLAutoConnect: true }); fable.serviceManager.addAndInstantiateServiceType('MeadowMySQLProvider', MeadowConnectionMySQL); fable.MeadowMySQLProvider.pool.query('SELECT 1 AS result', (error, rows, fields) => { if (error) { console.error(error); return; } console.log(`Connected: ${rows[0].result}`); });
Debug
Known issues
breakingMeadowConnectionMySQLAutoConnect must be set to true in config or provider options to auto-connect; otherwise connect() must be called manually.
fix
Set the flag in constructor options or call fable.MeadowMySQLProvider.connect() after service registration.
affects: >=0.0.1
deprecatedCallback-based query API: pool.query() uses callbacks. The package does not expose a Promise-based API.
fix
Wrap calls with util.promisify() or use a Promise wrapper: const query = util.promisify(pool.query).bind(pool);
affects: >=1.0.0
breakingService must be instantiated via addAndInstantiateServiceType, not new MeadowConnectionMySQL() directly.
fix
Always use fable.serviceManager.addAndInstantiateServiceType('MeadowMySQLProvider', MeadowConnectionMySQL).
affects: >=1.0.0
gotchaPassword may leak in connection log messages if connection fails. The package logs descriptive errors but does not redact passwords in all cases.
fix
Ensure logging is disabled or sanitized in production. Consider using environment variables for credentials.
affects: >=0.0.1
breakingDouble-connect guard: calling connect() on an already-connected instance logs an error and does nothing. No explicit return value or callback provided.
fix
Check if fable.MeadowMySQLProvider.pool exists before calling connect() again, or rely on the guard.
affects: >=0.0.1
gotchaConnection pool limit default is not documented; may default to mysql2's default (10 connections).
fix
Explicitly set ConnectionPoolLimit in config to avoid running out of connections under load.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'query')
Accessing pool.query before the service is fully registered or auto-connect disabled and connect() not called.
fix
Ensure MeadowConnectionMySQLAutoConnect: true in config, or call `fable.MeadowMySQLProvider.connect()` after addAndInstantiateServiceType.
Error: Pool is not connected
Calling pool.query after connection failure or before connect() completes.
fix
Wrap pool.query inside the callback of connectAsync, or use events to check pool status.
Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server
MySQL server uses caching_sha2_password plugin (MySQL 8+ default) and mysql2 default auth plugin may not be configured.
fix
Add `authPlugins: { sha256_password: undefined }` to mysql2 connection config, or set default auth plugin to mysql_native_password on server.
Error: Cannot find module 'fable'
Missing peer dependency 'fable'.
fix
Run: npm install fable meadow-connection-mysql (fable must be installed separately).
Upgrade
Version history
1.0.19latest on npm
Audit
Dependencies
mysql2requiredCore dependency for MySQL connection pooling and query execution.
fablerequiredRequired for Fable service provider integration and dependency injection.
Agent activity
2 hits · last 30 days
node
2
Resources
meadow-connection-mysql — npm install meadow-connection-mysql · libregistry