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

sets: {
        type: DataTypes.INTEGER,
      
      

      },

reps: {
        type: DataTypes.INTEGER,
      
      

      },

progression_notes: {
        type: DataTypes.TEXT,
      
      

      },

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

  physio_exercises.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.physio_exercises.belongsTo(db.injuries, {
      as: 'injury',
      foreignKey: {
        name: 'injuryId',
      },
      constraints: false,
    });

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




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

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



  return physio_exercises;
};


