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

full_name: {
        type: DataTypes.TEXT,
      
      

      },

graduation_year: {
        type: DataTypes.TEXT,
      
      

      },

current_role: {
        type: DataTypes.TEXT,
      
      

      },

organization: {
        type: DataTypes.TEXT,
      
      

      },

bio: {
        type: DataTypes.TEXT,
      
      

      },

phone_number: {
        type: DataTypes.TEXT,
      
      

      },

email: {
        type: DataTypes.TEXT,
      
      

      },

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

      },

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

      },

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

  alumni.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.alumni.hasMany(db.file, {
      as: 'photo',
      foreignKey: 'belongsToId',
      constraints: false,
      scope: {
        belongsTo: db.alumni.getTableName(),
        belongsToColumn: 'photo',
      },
    });


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

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



  return alumni;
};


