diff --git a/models/wishListItemModel.js b/models/wishListItemModel.js index b84d67a..eea5af3 100644 --- a/models/wishListItemModel.js +++ b/models/wishListItemModel.js @@ -4,41 +4,45 @@ const sequelize = require('../utils/dataBaseConnection'); const WishList = require('./wishListModel'); const Product = require('./productModel'); -const WishListItem = sequelize.define('wishListItem', { +const WishListItem = sequelize.define( + 'wishListItem', + { id: { - type: DataTypes.INTEGER(15), - allowNull: false, - autoIncrement: true, - primaryKey: true, - }, wishListId: { - type: DataTypes.INTEGER(15), - allowNull: false, - references: { - model: WishList, - key: 'id', - onDelete: 'CASCADE', - }, + type: DataTypes.INTEGER(15), + allowNull: false, + autoIncrement: true, + primaryKey: true, + }, + wishListId: { + type: DataTypes.INTEGER(15), + allowNull: false, + references: { + model: WishList, + key: 'id', + onDelete: 'CASCADE', + }, }, productId: { - type: DataTypes.INTEGER(15), - allowNull: true, - references: { - model: Product, - key: 'id', - onDelete: 'CASCADE', - }, + type: DataTypes.INTEGER(15), + allowNull: true, + references: { + model: Product, + key: 'id', + onDelete: 'CASCADE', + }, }, -}, { + }, + { freezeTableName: true, timestamps: false, -}); + } +); // Associations -WishListItem.belongsTo(WishList, { onDelete: 'cascade', hooks: true }, { foreignKey: 'wishListId' }); +WishListItem.belongsTo(WishList, { foreignKey: 'wishListId' }); WishList.hasMany(WishListItem, { foreignKey: 'wishListId' }); -WishListItem.belongsTo(Product, /*{ onDelete: 'cascade', hooks: true } ,*/ { foreignKey: 'productId' }); +WishListItem.belongsTo(Product, { foreignKey: 'productId' }); Product.hasMany(WishListItem, { foreignKey: 'productId' }); - module.exports = WishListItem;