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

default_quantity_cases: {
        type: DataTypes.INTEGER,
      
      

      },

notes: {
        type: DataTypes.TEXT,
      
      

      },

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

  saved_list_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.saved_list_items.belongsTo(db.saved_lists, {
      as: 'saved_list',
      foreignKey: {
        name: 'saved_listId',
      },
      constraints: false,
    });

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




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

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



  return saved_list_items;
};


