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

update_status: {
        type: DataTypes.ENUM,
      
      

        values: [

"received",


"validated",


"aggregated",


"rejected"

        ],

      },

received_at: {
        type: DataTypes.DATE,
      
      

      },

privacy_budget: {
        type: DataTypes.DECIMAL,
      
      

      },

gradient_blob_uri: {
        type: DataTypes.TEXT,
      
      

      },

validation_notes: {
        type: DataTypes.TEXT,
      
      

      },

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

  federated_learning_updates.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.federated_learning_updates.belongsTo(db.users, {
      as: 'user',
      foreignKey: {
        name: 'userId',
      },
      constraints: false,
    });

    db.federated_learning_updates.belongsTo(db.layout_models, {
      as: 'layout_model',
      foreignKey: {
        name: 'layout_modelId',
      },
      constraints: false,
    });

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




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

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



  return federated_learning_updates;
};


