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

weight: {
        type: DataTypes.DECIMAL,
      
      

      },

notes: {
        type: DataTypes.TEXT,
      
      

      },

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

  matrix_rows.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.matrix_rows.belongsTo(db.test_matrices, {
      as: 'test_matrix',
      foreignKey: {
        name: 'test_matrixId',
      },
      constraints: false,
    });

    db.matrix_rows.belongsTo(db.test_items, {
      as: 'test_item',
      foreignKey: {
        name: 'test_itemId',
      },
      constraints: false,
    });

    db.matrix_rows.belongsTo(db.skills, {
      as: 'skill',
      foreignKey: {
        name: 'skillId',
      },
      constraints: false,
    });




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

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



  return matrix_rows;
};


