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

quoted_at: {
        type: DataTypes.DATE,
      
      

      },

price: {
        type: DataTypes.DECIMAL,
      
      

      },

open: {
        type: DataTypes.DECIMAL,
      
      

      },

high: {
        type: DataTypes.DECIMAL,
      
      

      },

low: {
        type: DataTypes.DECIMAL,
      
      

      },

previous_close: {
        type: DataTypes.DECIMAL,
      
      

      },

change_amount: {
        type: DataTypes.DECIMAL,
      
      

      },

change_percent: {
        type: DataTypes.DECIMAL,
      
      

      },

volume: {
        type: DataTypes.DECIMAL,
      
      

      },

timeframe: {
        type: DataTypes.ENUM,
      
      

        values: [

"1min",


"5min",


"15min",


"30min",


"60min",


"daily",


"weekly",


"monthly"

        ],

      },

source: {
        type: DataTypes.TEXT,
      
      

      },

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

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




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

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



  return price_quotes;
};


