'use strict';
const { Model } = require('sequelize');

module.exports = (sequelize, DataTypes) => {
  class OrderItems extends Model {
    static associate(models) {
      OrderItems.belongsTo(models.Order, {
        foreignKey: "order_id"
      });

      OrderItems.belongsTo(models.Food, {
        foreignKey: "food_id"
      });
    }
  }

  OrderItems.init({
    quantity: {
      type: DataTypes.INTEGER,
      allowNull: false
    },
    harga: {
      type: DataTypes.INTEGER,
      allowNull: false
    },
    order_id: {
      type: DataTypes.INTEGER,
      allowNull: false
    },
    food_id: {
      type: DataTypes.INTEGER,
      allowNull: false
    },
  }, {
    sequelize,
    modelName: 'OrderItems',
    tableName: 'orders-items',
    timestamps: true
  });

  return OrderItems;
};