是否没有选项可以在 sequelize 模型中映射列名

2022-01-19 00:00:00 node.js mysql sequelize.js

我有一个给定的数据库,其列名又长又麻烦.有没有办法将表名映射到模型中更短、更具描述性的 propertyNames ?像

I have a given database with long, cumbersome columnnames. Isn't there any way to map the tablenames to shorter and more descriptive propertyNames in the model ? something like

var Employee = sql.define('Employee', {
    id : {type : Sequelize.INTEGER , primaryKey: true, map : "veryLongNameForJustTheId"}
},{
     tableName: 'cumbersomeTableName',
     timestamps: false
});;

推荐答案

id : {
    field: 'some_long_name_that_is_terrible_thanks_dba_guy',
    type : Sequelize.INTEGER ,
    primaryKey: true
}

指定一个字段"属性...就像那样^

Specify a 'field' attribute ... Like that ^

相关文章