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

excerpt: {
        type: DataTypes.TEXT,
      
      

      },

notes: {
        type: DataTypes.TEXT,
      
      

      },

relevance: {
        type: DataTypes.ENUM,
      
      

        values: [

"low",


"medium",


"high"

        ],

      },

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

  node_evidence_items.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.node_evidence_items.belongsTo(db.map_nodes, {
      as: 'node',
      foreignKey: {
        name: 'nodeId',
      },
      constraints: false,
    });

    db.node_evidence_items.belongsTo(db.source_items, {
      as: 'source_item',
      foreignKey: {
        name: 'source_itemId',
      },
      constraints: false,
    });

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




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

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



  return node_evidence_items;
};


