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 shelf_slots = sequelize.define(
    'shelf_slots',
    {
      id: {
        type: DataTypes.UUID,
        defaultValue: DataTypes.UUIDV4,
        primaryKey: true,
      },

facings: {
        type: DataTypes.INTEGER,
      
      

      },

max_quantity: {
        type: DataTypes.INTEGER,
      
      

      },

current_quantity: {
        type: DataTypes.INTEGER,
      
      

      },

slot_index: {
        type: DataTypes.INTEGER,
      
      

      },

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

  shelf_slots.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.shelf_slots.belongsTo(db.shelves, {
      as: 'shelf',
      foreignKey: {
        name: 'shelfId',
      },
      constraints: false,
    });

    db.shelf_slots.belongsTo(db.store_products, {
      as: 'store_product',
      foreignKey: {
        name: 'store_productId',
      },
      constraints: false,
    });




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

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



  return shelf_slots;
};


