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

relevance: {
        type: DataTypes.ENUM,
      
      

        values: [

"primary",


"secondary",


"mentioned"

        ],

      },

sentiment_score: {
        type: DataTypes.DECIMAL,
      
      

      },

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

  news_article_symbols.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.news_article_symbols.belongsTo(db.news_articles, {
      as: 'news_article',
      foreignKey: {
        name: 'news_articleId',
      },
      constraints: false,
    });

    db.news_article_symbols.belongsTo(db.market_symbols, {
      as: 'market_symbol',
      foreignKey: {
        name: 'market_symbolId',
      },
      constraints: false,
    });




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

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



  return news_article_symbols;
};


