'use strict';
const {
  Model
} = require('sequelize');
module.exports = (sequelize, DataTypes) => {
  class DiscountProduct extends Model {
    /**
     * Helper method for defining associations.
     * This method is not a part of Sequelize lifecycle.
     * The `models/index` file will call this method automatically.
     */
    static associate(models) {
      // define association here
      DiscountProduct.belongsTo(models.Discount, { foreignKey: 'discountId', as: 'discount' });
      DiscountProduct.belongsTo(models.Product, { foreignKey: 'productId', as: 'product' });
      DiscountProduct.belongsTo(models.Category, { foreignKey: 'categoryId', as: 'category' });
    }
  }
  DiscountProduct.init({
    discountId: DataTypes.INTEGER,
    productId: DataTypes.INTEGER,
    categoryId: DataTypes.INTEGER
  }, {
    sequelize,
    modelName: 'DiscountProduct',
  });
  return DiscountProduct;
};