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

pe_ratio: {
        type: DataTypes.DECIMAL,
      
      

      },

eps: {
        type: DataTypes.DECIMAL,
      
      

      },

market_cap: {
        type: DataTypes.DECIMAL,
      
      

      },

revenue: {
        type: DataTypes.DECIMAL,
      
      

      },

dividend_yield: {
        type: DataTypes.DECIMAL,
      
      

      },

beta: {
        type: DataTypes.DECIMAL,
      
      

      },

shares_outstanding: {
        type: DataTypes.DECIMAL,
      
      

      },

as_of_at: {
        type: DataTypes.DATE,
      
      

      },

source: {
        type: DataTypes.TEXT,
      
      

      },

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

  symbol_fundamentals.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.symbol_fundamentals.belongsTo(db.market_symbols, {
      as: 'market_symbol',
      foreignKey: {
        name: 'market_symbolId',
      },
      constraints: false,
    });




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

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



  return symbol_fundamentals;
};


