sequelize model default value code example
Example 1: sequelize model default value
const Pug = db.define('pugs', {
name: {
type: Sequelize.STRING
allowNull: false
},
bio: {
name: Sequelize.TEXT
},
age: {
type: Sequelize.INTEGER,
validate: {
min: 0,
max: 100
}
},
birthday: {
type: Sequelize.DATE,
defaultValue: Date.now()
},
colors: {
type: Sequelize.ENUM('black', 'fawn')
},
toys: {
type: Sequelize.ARRAY(Sequelize.TEXT)
},
adoptedStatus: {
type: Sequelize.BOOLEAN
}
})
Example 2: sequelize migration default value
queryInterface.addColumn('OrderBackups', 'my_column', {
type: Sequelize.INTEGER,
defaultValue: 0
})