Is it possible to get the datatype of a given field from a sequelize model. Assume we have a module defined like so
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 say figure out the data type for firstName. Is there any method within model which can achieve this?
You can access it this way:
User.tableAttributes.firstName.type.constructor.key
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With