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

relevance_score: {
        type: DataTypes.DECIMAL,
      
      

      },

citation_note: {
        type: DataTypes.TEXT,
      
      

      },

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

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

    db.output_citations.belongsTo(db.knowledge_chunks, {
      as: 'knowledge_chunk',
      foreignKey: {
        name: 'knowledge_chunkId',
      },
      constraints: false,
    });




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

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



  return output_citations;
};


