Readlebee/server/sequelize/associations/Status.js

32 lines
556 B
JavaScript
Raw Normal View History

module.exports = models => {
const {
Status,
2020-01-25 21:52:37 +01:00
PermissionLevel,
User,
ShelfItem,
2020-01-25 21:52:37 +01:00
Reaction,
} = models;
Status.belongsTo(User, {
foreignKey: 'userId',
onDelete: 'CASCADE',
});
Status.belongsTo(PermissionLevel, {
foreignKey: 'permissionLevel',
onDelete: 'SET NULL',
});
Status.belongsTo(ShelfItem, {
foreignKey: 'shelfItemId',
onDelete: 'SET NULL',
});
2020-01-25 21:52:37 +01:00
Status.hasMany(Reaction.scope('Status'), {
foreignKey: 'targetId',
constraints: false,
as: 'Reactions',
});
return Status;
}