Create a model
After having set up the sequelize connection, we have to implement our model.
As seen in the previous section, we tell Sequelize that we will have the User
model using this method
sequelize.addModels([User]);
.
You now see all of the required features to set up it.
@Table
This decorator will allow you to configure our representation of the data, and here are some parameters:
{
timestamps
:true
,
paranoid
:true
,
underscored
:false
,
freezeTableName
:true
,
tableName
:
'my_very_custom_table_name'
}
The timestamp
parameter will tell you that you want to have an updatedAt
and deletedAt
columns. The paranoid
parameter allows you to soft delete data instead of removing it to lose your data. If you pass true
, Sequelize will expected a deletedAt
column in oder to set the date of the remove action.
The underscored
parameter will automatically transform all of the camelcase columns into underscored columns.
The freezTableName
will provide a way...