mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-12-24 18:02:49 +00:00
408ab7ae1d
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>
42 lines
886 B
JavaScript
42 lines
886 B
JavaScript
'use strict'
|
|
// external modules
|
|
var Sequelize = require('sequelize')
|
|
|
|
module.exports = function (sequelize, DataTypes) {
|
|
var Author = sequelize.define('Author', {
|
|
id: {
|
|
type: Sequelize.INTEGER,
|
|
primaryKey: true,
|
|
autoIncrement: true
|
|
},
|
|
color: {
|
|
type: DataTypes.STRING
|
|
}
|
|
}, {
|
|
indexes: [
|
|
{
|
|
unique: true,
|
|
fields: ['noteId', 'userId']
|
|
}
|
|
],
|
|
classMethods: {
|
|
associate: function (models) {
|
|
Author.belongsTo(models.Note, {
|
|
foreignKey: 'noteId',
|
|
as: 'note',
|
|
constraints: false,
|
|
onDelete: 'CASCADE',
|
|
hooks: true
|
|
})
|
|
Author.belongsTo(models.User, {
|
|
foreignKey: 'userId',
|
|
as: 'user',
|
|
constraints: false,
|
|
onDelete: 'CASCADE',
|
|
hooks: true
|
|
})
|
|
}
|
|
}
|
|
})
|
|
return Author
|
|
}
|