Sequelize - Prevent Destroying Row When Used Somewhere Else In Association
Is there way to make Sequelize.js throw exception when I try destroy row what is used somewhere in association? As example let's have table for Roles and table for Users. They have
Solution 1:
You can control this in the association using the onDelete and onUpdate, like this:
User.hasMany(Roles, { foreignKey: "whatever", onDelete: 'restrict', onUpdate: 'restrict'});
The Foreign Key section of the manual mentions the options ...
Post a Comment for "Sequelize - Prevent Destroying Row When Used Somewhere Else In Association"