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

given_at: {
        type: DataTypes.DATE,
      
      

      },

overall_score: {
        type: DataTypes.DECIMAL,
      
      

      },

compliance_score: {
        type: DataTypes.DECIMAL,
      
      

      },

brand_fit_score: {
        type: DataTypes.DECIMAL,
      
      

      },

conversion_intent_score: {
        type: DataTypes.DECIMAL,
      
      

      },

empathy_score: {
        type: DataTypes.DECIMAL,
      
      

      },

risk_boldness_score: {
        type: DataTypes.DECIMAL,
      
      

      },

freeform_notes: {
        type: DataTypes.TEXT,
      
      

      },

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

  feedback_entries.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.feedback_entries.belongsTo(db.generation_outputs, {
      as: 'generation_output',
      foreignKey: {
        name: 'generation_outputId',
      },
      constraints: false,
    });

    db.feedback_entries.belongsTo(db.users, {
      as: 'given_by',
      foreignKey: {
        name: 'given_byId',
      },
      constraints: false,
    });




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

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



  return feedback_entries;
};


