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

created_at_ts: {
        type: DataTypes.DATE,
      
      

      },

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

  business_categories.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.business_categories.belongsTo(db.businesses, {
      as: 'business',
      foreignKey: {
        name: 'businessId',
      },
      constraints: false,
    });

    db.business_categories.belongsTo(db.categories, {
      as: 'category',
      foreignKey: {
        name: 'categoryId',
      },
      constraints: false,
    });




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

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



  return business_categories;
};


