'deleting all entries with FK when PK entry is deleted sequelize
I have a post and a notification model. notification has a onPostId FK. When a post is deleted how can I let sequelize know to delete all the notifications that contain that post ID?
Current here is where I set the relationships
post.hasMany(notification, { foreignKey: 'onPostId' }, { onDelete: 'cascade' });
notification.belongsTo(post, { foreignKey: 'onPostId' }, { onDelete: 'cascade' });
On deleting a post I see no alterations to the notifications in my db
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
