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

caught_at: {
        type: DataTypes.DATE,
      
      

      },

weight: {
        type: DataTypes.DECIMAL,
      
      

      },

length: {
        type: DataTypes.DECIMAL,
      
      

      },

quality_grade: {
        type: DataTypes.ENUM,
      
      

        values: [

"standard",


"fresh",


"premium"

        ],

      },

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

  fishing_catches.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.fishing_catches.belongsTo(db.player_profiles, {
      as: 'player_profile',
      foreignKey: {
        name: 'player_profileId',
      },
      constraints: false,
    });

    db.fishing_catches.belongsTo(db.fishing_spots, {
      as: 'fishing_spot',
      foreignKey: {
        name: 'fishing_spotId',
      },
      constraints: false,
    });

    db.fishing_catches.belongsTo(db.fish_species, {
      as: 'fish_species',
      foreignKey: {
        name: 'fish_speciesId',
      },
      constraints: false,
    });




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

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



  return fishing_catches;
};


