//sequelize-auto -h "数据库地址" -d "数据库名" -u "用户名" -x "密码" -p "端口号" --dialect mysql
sequelize-auto -o "./model" -d test -h 127.0.0.1 -u root -p 3306 -x 123456 -e mysql
Options:
--help Show help [boolean]
--version Show version number [boolean]
-h, --host IP/Hostnamefor the database. [string]
-d, --database Database name. [string]
-u, --user Usernamefor database. [string]
-x, --pass Passwordfor database. If specified without providing
a password, it will be requested interactively from
the terminal.
-p, --port Port number for database (not for sqlite). Ex:
MySQL/MariaDB: 3306, Postgres: 5432, MSSQL: 1433
[number]
-c, --config Path to JSON file forSequelize-Auto options and
Sequelize's constructor "options" flag object as
defined here:
https://sequelize.org/master/class/lib/sequelize.js~Sequelize.html#instance-constructor-constructor
[string]
-o, --output What directory to place the models. [string]
-e, --dialect The dialect/engine that you're using: postgres,
mysql, sqlite, mssql [string]
-a, --additional Path to JSON file containing model options (for all
tables). See the options: https://sequelize.org/master/class/lib/model.js~Model.html#static-method- init
[string]
--indentation Numberof spaces to indent [number]
-t, --tables Space-separated names of tables to import [array]
-T, --skipTables Space-separated names of tables to skip [array]
--caseModel, --cm Setcaseof model names: c|l|o|p|u
c = camelCase
l = lower_case
o = original (default)
p = PascalCase
u = UPPER_CASE
--caseProp, --cp Setcaseof property names: c|l|o|p|u
--caseFile, --cf Setcaseof file names: c|l|o|p|u|k
k = kebab-case
--noAlias Avoid creating alias `as` property in relations
[boolean]
--noInitModels Prevent writing the init-models file [boolean]
-n, --noWrite Prevent writing the models to disk [boolean]
-s, --schema Database schema from which to retrieve tables[string]
-v, --views Include database views in generated models [boolean]
-l, --lang LanguageforModeloutput: es5|es6|esm|ts
es5 = ES5CJS modules (default)
es6 = ES6CJS modules
esm = ES6ESM modules
ts = TypeScript [string]
--useDefine Use`sequelize.define` instead of`init`for es6|esm|ts
--singularize, --sg Singularize model and file names from plural table
names [boolean]
$and: {a: 5} // AND (a = 5)$or: [{a: 5}, {a: 6}] // (a = 5 OR a = 6)$gt: 6, // > 6$gte: 6, // >= 6$lt: 10, // < 10$lte: 10, // <= 10$ne: 20, // != 20$not: true, // IS NOT TRUE$between: [6, 10], // BETWEEN 6 AND 10$notBetween: [11, 15], // NOT BETWEEN 11 AND 15$in: [1, 2], // IN [1, 2]$notIn: [1, 2], // NOT IN [1, 2]$like: '%hat', // LIKE '%hat'$notLike: '%hat'// NOT LIKE '%hat'$iLike: '%hat'// ILIKE '%hat' (case insensitive) (PG only)$notILike: '%hat'// NOT ILIKE '%hat' (PG only)$like: { $any: ['cat', 'hat']}
// LIKE ANY ARRAY['cat', 'hat'] - also works for iLike and notLike$overlap: [1, 2] // && [1, 2] (PG array overlap operator)$contains: [1, 2] // @> [1, 2] (PG array contains operator)$contained: [1, 2] // <@ [1, 2] (PG array contained by operator)$any: [2,3] // ANY ARRAY[2, 3]::INTEGER (PG only)$col: 'user.organization_id'// = "user"."organization_id", with dialect specific column identifiers, PG in this example
A.hasOne(B, { /* 参数 */ }); // A 有一个 B
A.belongsTo(B, { /* 参数 */ }); // A 属于 B
A.hasMany(B, { /* 参数 */ }); // A 有多个 B
A.belongsToMany(B, { through: 'C', /* 参数 */ }); // A 属于多个 B , 通过联结表 C