nodejh / sequelize-automate

Automatically generate bare sequelize models from your database.
MIT License
116 stars 22 forks source link

sequelize/sequelize-auto可以通过-t 表名指定某一张表,这个要怎么指定 #37

Open TRIS-H opened 4 years ago

nodejh commented 4 years ago
  1. 可以用 --match, -m ,值是一个正则表达式
  2. 也可以在配置文件中,使用 tables/skipTables/match 来设置
TRIS-H commented 4 years ago

假设我的表名为my_table_a, 我这样输入: sequelize-automate -h ${sql.host} -d ${sql.database} -u ${sql.username} -p ${sql.password} -P ${sql.port} -m /my_table_a/ 还是生成了全部,是哪里的问题?

TRIS-H commented 4 years ago

瞄了下源码: const dbOptions = _.assign({}, { database: argv.d, username: argv.u, password: argv.p, dialect: argv.e, host: argv.h || '127.0.0.1', port: argv.P || getDefaultPort(argv.e), }, configFile ? configFile.dbOptions : {});

const options = _.assign({}, { type: argv.t || 'js', camelCase: !!argv.C, dir: argv.o || path.resolve(${process.cwd()}/models), emptyDir: !!argv.r, }, configFile ? configFile.options : {});

貌似-m并无传递

nodejh commented 4 years ago

确实没有,我周末解决一下。试试用配置文件的方式?

// sequelize-automate.config.js
module.exports = {
  dbOptions: {
    database: "test",
    username: "root",
    password: "root",
    dialect: "mysql",
    host: "localhost",
    port: 3306,
    logging: false
  },
  options: {
    type: "js",
    dir: "models",
    tables: ["my_table_a"] // 只生成 my_table_a 的 model
 }
}
$ sequelize-automate -c "./sequelize-automate.config.js"