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

score: {
        type: DataTypes.DECIMAL,
      
      

      },

comments: {
        type: DataTypes.TEXT,
      
      

      },

recommendation: {
        type: DataTypes.ENUM,
      
      

        values: [

"approve",


"revise",


"reject"

        ],

      },

evaluated_at: {
        type: DataTypes.DATE,
      
      

      },

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

  grant_evaluations.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.grant_evaluations.belongsTo(db.grant_applications, {
      as: 'application',
      foreignKey: {
        name: 'applicationId',
      },
      constraints: false,
    });

    db.grant_evaluations.belongsTo(db.users, {
      as: 'evaluator_user',
      foreignKey: {
        name: 'evaluator_userId',
      },
      constraints: false,
    });

    db.grant_evaluations.belongsTo(db.organizations, {
      as: 'organizations',
      foreignKey: {
        name: 'organizationsId',
      },
      constraints: false,
    });




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

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



  return grant_evaluations;
};


