const config = require('../../config');
const providers = config.providers;
const crypto = require('crypto');
const bcrypt = require('bcrypt');
const moment = require('moment');

module.exports = function(sequelize, DataTypes) {
  const frequently_bought_together_items = sequelize.define(
    'frequently_bought_together_items',
    {
      id: {
        type: DataTypes.UUID,
        defaultValue: DataTypes.UUIDV4,
        primaryKey: true,
      },

sort_order: {
        type: DataTypes.INTEGER,
      
      

      },

bundle_discount_percent: {
        type: DataTypes.DECIMAL,
      
      

      },

      importHash: {
        type: DataTypes.STRING(255),
        allowNull: true,
        unique: true,
      },
    },
    {
      timestamps: true,
      paranoid: true,
      freezeTableName: true,
    },
  );

  frequently_bought_together_items.associate = (db) => {


/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity












































//end loop



    db.frequently_bought_together_items.belongsTo(db.frequently_bought_together_groups, {
      as: 'group',
      foreignKey: {
        name: 'groupId',
      },
      constraints: false,
    });

    db.frequently_bought_together_items.belongsTo(db.products, {
      as: 'product',
      foreignKey: {
        name: 'productId',
      },
      constraints: false,
    });




    db.frequently_bought_together_items.belongsTo(db.users, {
      as: 'createdBy',
    });

    db.frequently_bought_together_items.belongsTo(db.users, {
      as: 'updatedBy',
    });
  };



  return frequently_bought_together_items;
};


