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

trust_score: {
        type: DataTypes.INTEGER,
      
      

      },

trust_tier: {
        type: DataTypes.ENUM,
      
      

        values: [

"unverified",


"basic",


"verified",


"trusted",


"elite"

        ],

      },

score_last_calculated_at: {
        type: DataTypes.DATE,
      
      

      },

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

      },

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

      },

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

      },

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

      },

risk_flags_summary: {
        type: DataTypes.TEXT,
      
      

      },

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

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




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

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



  return trust_profiles;
};


