2020-01-14 23:26:39 +01:00
|
|
|
module.exports = models => {
|
|
|
|
const {
|
|
|
|
Shelf,
|
|
|
|
User,
|
|
|
|
ShelfItem,
|
|
|
|
PermissionLevel,
|
|
|
|
} = models;
|
|
|
|
|
|
|
|
Shelf.belongsTo(User, {
|
|
|
|
foreignKey: 'userId',
|
|
|
|
onDelete: 'CASCADE',
|
|
|
|
});
|
|
|
|
|
|
|
|
Shelf.belongsTo(PermissionLevel, {
|
|
|
|
foreignKey: 'permissionLevel',
|
|
|
|
onDelete: 'SET NULL',
|
|
|
|
});
|
|
|
|
|
|
|
|
Shelf.belongsTo(User, {
|
|
|
|
foreignKey: 'permissionLevel',
|
|
|
|
onDelete: 'CASCADE',
|
|
|
|
});
|
|
|
|
|
2020-01-25 21:52:37 +01:00
|
|
|
Shelf.hasMany(ShelfItem, {
|
|
|
|
foreignKey: 'shelfId',
|
|
|
|
});
|
2020-01-14 23:26:39 +01:00
|
|
|
|
|
|
|
return Shelf;
|
|
|
|
}
|