diff options
author | Sheogorath | 2018-05-25 14:54:00 +0200 |
---|---|---|
committer | Sheogorath | 2018-05-25 14:55:18 +0200 |
commit | 408ab7ae1dfa5d1c7dedb2f9fde239596520b2e6 (patch) | |
tree | 65efa501b128c268497e9bf226a9f1332d8c8e48 /lib/models/author.js | |
parent | 8aa5c03213fb8809c4d41f95ee6b8d8e2967812a (diff) |
Use cascaded deletes
When we delete a user we should delete all the notes that belong to this
user including the revisions of these notes.
Signed-off-by: Sheogorath <sheogorath@shivering-isles.com>
Diffstat (limited to '')
-rw-r--r-- | lib/models/author.js | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/models/author.js b/lib/models/author.js index 8b4f74e5..03f832a4 100644 --- a/lib/models/author.js +++ b/lib/models/author.js @@ -24,12 +24,16 @@ module.exports = function (sequelize, DataTypes) { Author.belongsTo(models.Note, { foreignKey: 'noteId', as: 'note', - constraints: false + constraints: false, + onDelete: 'CASCADE', + hooks: true }) Author.belongsTo(models.User, { foreignKey: 'userId', as: 'user', - constraints: false + constraints: false, + onDelete: 'CASCADE', + hooks: true }) } } |