Registry / database / egg-mysql-sequelize-auto

egg-mysql-sequelize-auto

JSON →
library1.1.0jsnpmunverified

A CLI tool that automatically generates Sequelize model files for Egg.js from a MySQL database. Version 1.1.0, low release cadence (last update 2020). Key differentiator: generates TypeScript models with type definitions, specifically for Egg.js framework. Alternative to sequelize-auto with Egg.js integration and opinionated output structure. Produces both model and definition files under app/model/ and app/model/define/. Supports table selection, overwrite, and configurable output directory.

npm install egg-mysql-sequelize-auto
INSTALL
IMPORT
SIG · EGG-MYSQL-SEQUELIZ
E
egg-mysql-sequelize-auto
databasejavascriptv1.1.0
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.

Sequelize
import { Sequelize } from 'sequelize'
const sequelize = require('sequelize')
Sequelize v6+ requires named import
Application
import { Application } from 'egg'
import app from 'egg'
Egg.js exports Application type
Model
import { Model, CreationAttributes } from 'sequelize'
import { Model } from 'sequelize/types'
CreationAttributes is needed for strict typing since v6

Shows installation, configuration via npm script, and CLI execution to generate Egg.js Sequelize models from a MySQL database.

// 1. Install globally or as devDependency npm i -D egg-mysql-sequelize-auto // 2. Create script in package.json: "scripts": { "model": "mysql-sequelize-auto -h localhost -d mydb -p 3306 -u root -x 'password' -o './app/model' -t users" } // 3. Run: npm run model // 4. Generated files: // app/model/users.ts (model) // app/model/define/users.d.ts (type definitions)
Debug
Known issues
breakingTable name must be provided with -t option; without it, no models are generated.
fix
Always pass -t tablename or use -- --t=tablename after the script.
affects: >=1.0.0
deprecatedCLI uses mysql2 driver; older MySQL versions might not be supported.
fix
Use MySQL 8+ or ensure mysql2 compatibility.
affects: >=1.0.0
gotchaOutput directory './app/model' is relative to project root, not where command is run.
fix
Always specify absolute path or ensure CWD is project root.
affects: >=1.0.0
gotchaGenerated models reference app.Sequelize, which must be configured via egg-sequelize plugin.
fix
Install and configure egg-sequelize in config/plugin.js: exports.sequelize = { enable: true, package: 'egg-sequelize' }
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'mysql2'
mysql2 is a peer dependency not automatically installed.
fix
Run: npm install mysql2 --save
TypeError: app.model.define is not a function
egg-sequelize plugin is not enabled or configured.
fix
Add 'egg-sequelize' to package.json and enable in config/plugin.js
No models generated: No table specified
Missing -t option in CLI command.
fix
Add -t tableName to command or use -- --t=tableName
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies
eggrequiredRuntime dependency: models are Egg.js app modules
sequelizerequiredGenerated models extend Sequelize Model class
mysql2optionalUsed to connect to MySQL database for introspection
Agent activity
15 hits · last 30 days
node
12
Amazon
1
Resources
egg-mysql-sequelize-auto — npm install egg-mysql-sequelize-auto · libregistry