How can I create a default value that is generated programmatically upon creation of a new instance of a Sequelize model? I've read how to do this somewhere, but can't find it anywhere. I thought this had something to do with classMethods, but I can't figure out what that method should be called.
For example:
sequelize.define('Account', {
name: DataTypes.STRING
}, {
classMethods: {
something: function (instance) {
instance.name = 'account12345';
}
}
});
models.account.create(function (account) {
console.log(account.name); // Echos "account12345" or whatever I
});
If you could point me in the right direction, it would be greatly appreciated.