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

importDate: {
        type: DataTypes.DATE,
      
      

      },

deviceCode: {
        type: DataTypes.TEXT,
      
      

      },

fileName: {
        type: DataTypes.TEXT,
      
      

      },

totalRecords: {
        type: DataTypes.INTEGER,
      
      

      },

successCount: {
        type: DataTypes.INTEGER,
      
      

      },

errorCount: {
        type: DataTypes.INTEGER,
      
      

      },

errorDetailsJson: {
        type: DataTypes.TEXT,
      
      

      },

periodFrom: {
        type: DataTypes.DATE,
      
      

      },

periodTo: {
        type: DataTypes.DATE,
      
      

      },

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

  biometric_imports.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.biometric_imports.belongsTo(db.users, {
      as: 'importedByUser',
      foreignKey: {
        name: 'importedByUserId',
      },
      constraints: false,
    });




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

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



  return biometric_imports;
};


