There are too few materials that can be found in China, so I find the materials in English documents, translate and share them
caseModel: the original table name bus_shop will automatically generate the definition return sequelize.define('busShop', {
caseProp: the original field name bus_name will automatically generate the definition shopName: { field: 'shop_name'},
caseFile: the generated js file name becomesbusShop.js
Configure additional parameters
new SequelizeAuto(database,username, password, {
// ...
caseModel: 'c',
caseProp: 'c',
caseFile: 'c',
// ...
});
参数:c|l|o|p|u
c = camelCase
l = lower_case
o = original (default)
p = PascalCase
u = UPPER_CASE
Comes with Chinese api documentation
Install
npm install sequelize-auto
example
Note: The abbreviated parameter is for the command line, configure new SequelizeAuto with the full name, do not bring –, see the hump example above
sequelize-auto -o "./models" -d sequelize_auto_test -h localhost -u my_username -p 5432 -x my_password -e postgres
Options:
--help help [boolean]
--version show version number [boolean]
-h, --host IP/hostname of database. (string)
-d, --database Database name. (string)
-u, --user Database username. (string)
-x, --pass Database password. If a password is not provided, it will be interactively requested from the terminal.
-p, --port The port number of the database (not sqlite). Example: MySQL/MariaDB: 3306, Postgres: 5432, MSSQL: 1433 (quantity)
-c, --config sequelize - auto options and path to JSON file
Sequelize's constructor "options" flag object is defined: https://sequelize .org/master/class/lib/sequelize.js~Sequelize.html#instance-constructor-constructor (string)
-o, --output Directory to place models. (string)
-e, --dialect The dialect/engine you are using: postgres, Mysql, sqlite, MSSQL [string]
-a, --additional Path to JSON file containing model options). See item: https://sequelize.org/master/class/lib/model.js~Model.html#static-method-init (string)
--indentation number of spaces for indentation [Number]
-t, --tables space-separated table names to import [array]
-T, --skiiptables space-separated table names to skip [array]
--caseModel, --cm set model Case of names: c|l|o|p|u
c = camelCase
l = lower_case
o = original (default)
p = PascalCase
u = UPPER_CASE
–caseProp, –cp Set property name case: c|l|o| p|u
--caseFile, --cf set the case of the filename: c|l|o|p|u|k
k = kebab-case
--noAlias avoid creating alias "as" attributes in relations (boolean)
--noInitModels suppress writing to init-models file [boolean]
-n, --noWrite suppress writing models to disk [boolean]
-s, --schema retrieve table's database schema [string]
-v, --views include database views in generated model [boolean]
-l, --lang model output language: es5|es6|esm|ts
es5 = es5 CJS module (default)
es6 = es6 CJS module
esm = ES6 esm module
ts = TypeScript [string]
--useDefine for es6|esm|ts use ' sequel .define ' instead of ' init '
--singularize, --sg Singularize model and filenames from plural table name[ boolean ]