MySQL plugin for the Egg.js framework (current stable version: 2.x, latest 3.0.0-RC11). It provides a thin wrapper around ali-rds, offering convenient CRUD operations, connection pooling, and transaction support. Key differentiators: seamless integration with Egg.js lifecycle and configuration, supports multi-instance databases, and follows Egg's convention-over-configuration plugin model. Release cadence is irregular; major version updates may align with Egg.js breaking changes. Not to be confused with other MySQL libraries—this is Egg-specific and not a general-purpose driver.
npm install egg-mysql-exNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Enable egg-mysql plugin, configure a single MySQL client, and use app.mysql.query in a controller.
Add exports.mysql = { enable: true, package: 'egg-mysql' } to config/plugin.js.Use async/await: const result = await app.mysql.query(sql);
Use exports.mysql = { clients: { db1: { ... } }, default: {...} } instead of exports.mysql = { db1: {...} }.Wrap transaction calls in try/catch/finally and use manual control carefully; refer to ali-rds documentation.
Ensure config/plugin.js has exports.mysql = { enable: true, package: 'egg-mysql' }; and config/config.default.js has valid exports.mysql.client configuration.Use app.mysql directly for single instance, or switch to clients configuration with multiple databases.
Verify MySQL host, port, user, password in config/config.default.js.