Data Field Type from Continuation Model

Is it possible to get the data type of this field from the sequelize model. Suppose we have a module defined as follows:

User = sequelize.define 'User',
{
 id:
   type: DataTypes.UUID
   primaryKey: true
   defaultValue: DataTypes.UUIDV4
 firstName:
   type: DataTypes.STRING
   allowNull: false
 middleName:
   type: DataTypes.STRING
   allowNull: true
   defaultValue: null
 lastName:
   type: DataTypes.STRING
   allowNull: true
   defaultValue: null
}

I need to specify the data type for firstName. Is there any method in the model that can achieve this?

+4
source share
1 answer

You can access it this way:

User.tableAttributes.firstName.type.constructor.key
+4
source

Source: https://habr.com/ru/post/1625362/


All Articles