Exploring the various Sequelize data types and when to use them
As explained earlier, Sequelize offers us various data types to help map our model’s attributes to their respective database management system (DBMS) column types. Next is a list of what Sequelize has to offer, along with a brief explanation.
STRING
The STRING
data type refers to a Variable Character Field (VARCHAR) column type, which is a non-fixed character column. The maximum storage for this column type varies depending on the DBMS. VARCHAR
fields usually contain meta information to help optimize the DBMS’ query planner. MySQL explicitly adds another byte to the column’s prefix header if the size of the string is greater than 255 bytes. A query planner could use this information to help alleviate pressure from memory, or the central processing unit (CPU), when retrieving/collecting/analyzing the data. To call VARCHAR
with a fixed paging length, you would define the column as DataTypes.STRING...