1
0
Fork 0
mirror of https://gitlab.com/Alamantus/Readlebee.git synced 2025-05-21 01:21:16 +02:00
Readlebee/server/sequelize/associations/Review.js

32 lines
568 B
JavaScript
Raw Normal View History

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