Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there no option to map the column name in sequelize model

Tags:

People also ask

How do you find the table name in Sequelize model?

Accessing model name: model.name . Accessing model table name: model. tableName . Note: model as used above is an instance of sequelize model.

How do I make a column Sequelize?

To add or delete columns in Sequelize CLI, we can use the sequelize migration:create command to create a migration file. Then we call addColumn to add a column and removeColumn to remove a column in the migration file. to create a migration file. in the migration file.

How do you make a Sequelize use singular table names?

const People = sequelize. define('people', { name: DataTypes. STRING, }, { hooks: { beforeCount (options) { options. raw = true; } }, tableName: 'people', name: { singular: 'person', plural: 'people' } });


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
});;