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

score: {
        type: DataTypes.DECIMAL,
      
      

      },

grade_letter: {
        type: DataTypes.ENUM,
      
      

        values: [

"A",


"B",


"C",


"D",


"E",


"F",


"P",


"N"

        ],

      },

remarks: {
        type: DataTypes.TEXT,
      
      

      },

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

  assessment_results.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.assessment_results.belongsTo(db.organizations, {
      as: 'organization',
      foreignKey: {
        name: 'organizationId',
      },
      constraints: false,
    });

    db.assessment_results.belongsTo(db.assessments, {
      as: 'assessment',
      foreignKey: {
        name: 'assessmentId',
      },
      constraints: false,
    });

    db.assessment_results.belongsTo(db.students, {
      as: 'student',
      foreignKey: {
        name: 'studentId',
      },
      constraints: false,
    });




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

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



  return assessment_results;
};


