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

total_score: {
        type: DataTypes.DECIMAL,
      
      

      },

rank: {
        type: DataTypes.INTEGER,
      
      

      },

consent_to_publish: {
        type: DataTypes.BOOLEAN,
      
        allowNull: false,
        defaultValue: false,
      
      

      },

published: {
        type: DataTypes.BOOLEAN,
      
        allowNull: false,
        defaultValue: false,
      
      

      },

note: {
        type: DataTypes.TEXT,
      
      

      },

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

  top_student_features.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.top_student_features.belongsTo(db.exams, {
      as: 'exam',
      foreignKey: {
        name: 'examId',
      },
      constraints: false,
    });

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




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

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



  return top_student_features;
};


