How do we get the ENUM values of a model after defining it in Sequelize.js?
For example, we define our model as:
sequelize.define('model', {
states: {
type: Sequelize.ENUM,
values: ['active', 'pending', 'deleted']
}
})
How do we get the pre-defined ['active', 'pending' ,'deleted']
values from this model?
The ENUM values in a schema can be found in the rawAttributes
property of the model.
var Model = sequelize.define('model', { states: { type: Sequelize.ENUM, values: ['active', 'pending', 'deleted'] } }); console.log(Model.rawAttributes.states.values); // logs ['active', 'pending', 'deleted'] in console
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