2020-01-14 23:26:39 +01:00
|
|
|
module.exports = models => {
|
|
|
|
const {
|
|
|
|
Status,
|
2020-01-25 21:52:37 +01:00
|
|
|
PermissionLevel,
|
2020-01-14 23:26:39 +01:00
|
|
|
User,
|
|
|
|
ShelfItem,
|
2020-01-25 21:52:37 +01:00
|
|
|
Reaction,
|
2020-01-14 23:26:39 +01:00
|
|
|
} = 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'), {
|
2020-01-15 22:01:14 +01:00
|
|
|
foreignKey: 'targetId',
|
|
|
|
constraints: false,
|
|
|
|
as: 'Reactions',
|
|
|
|
});
|
|
|
|
|
2020-01-14 23:26:39 +01:00
|
|
|
return Status;
|
|
|
|
}
|