Readlebee/server/sequelize/associations/BookReference.js

23 lines
432 B
JavaScript
Raw Normal View History

module.exports = models => {
const {
BookReference,
Review,
} = models;
2020-01-25 21:52:37 +01:00
BookReference.hasMany(Review, {
as: 'Interactions',
foreignKey: 'bookReferenceId',
});
BookReference.hasMany(Review.scope('Text'), {
as: 'Reviews',
foreignKey: 'bookReferenceId',
});
BookReference.hasMany(Review.scope('Rating'), {
as: 'Ratings',
2020-01-25 21:52:37 +01:00
foreignKey: 'bookReferenceId',
});
return BookReference;
}