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

set_number: {
        type: DataTypes.INTEGER,
      
      

      },

reps: {
        type: DataTypes.INTEGER,
      
      

      },

weight: {
        type: DataTypes.DECIMAL,
      
      

      },

weight_unit: {
        type: DataTypes.ENUM,
      
      

        values: [

"kg",


"lb"

        ],

      },

rpe: {
        type: DataTypes.INTEGER,
      
      

      },

notes: {
        type: DataTypes.TEXT,
      
      

      },

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

  strength_sets.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.strength_sets.belongsTo(db.workout_sessions, {
      as: 'workout_session',
      foreignKey: {
        name: 'workout_sessionId',
      },
      constraints: false,
    });

    db.strength_sets.belongsTo(db.exercises, {
      as: 'exercise',
      foreignKey: {
        name: 'exerciseId',
      },
      constraints: false,
    });




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

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



  return strength_sets;
};


