Sequelize onDelete not working

I have associations between the two models that are defined below:

For contact model (in a separate file)

classMethods: { associate: function (models){ Contact.belongsTo(models.User) } } 

For the user (in a separate file)

 classMethods: { associate: function (models){ User.hasMany(models.Contact, {onDelete: 'CASCADE'}) } } 

The problem is that when a user is deleted, the contact associated with the user does not remove any advice about what I am doing wrong would be helpful?

Thanks in advance

+2
javascript associations has-many
source share
1 answer

I think you need to define it differently.

 Contact.belongsTo(models.Users, { foreignKeyConstraint: true , onDelete: 'cascade' }) 
+4
source share

All Articles