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

executed_at: {
        type: DataTypes.DATE,
      
      

      },

quantity: {
        type: DataTypes.DECIMAL,
      
      

      },

price: {
        type: DataTypes.DECIMAL,
      
      

      },

fees: {
        type: DataTypes.DECIMAL,
      
      

      },

venue: {
        type: DataTypes.TEXT,
      
      

      },

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

  paper_trades.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.paper_trades.belongsTo(db.paper_orders, {
      as: 'paper_order',
      foreignKey: {
        name: 'paper_orderId',
      },
      constraints: false,
    });




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

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



  return paper_trades;
};


