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

name: {
        type: DataTypes.TEXT,
      
      

      },

weather_type: {
        type: DataTypes.ENUM,
      
      

        values: [

"sunny",


"rain",


"storm",


"cloudy",


"fog",


"heat_wave",


"wind"

        ],

      },

temperature_c: {
        type: DataTypes.DECIMAL,
      
      

      },

wind_speed: {
        type: DataTypes.DECIMAL,
      
      

      },

rain_intensity: {
        type: DataTypes.DECIMAL,
      
      

      },

has_thunder: {
        type: DataTypes.BOOLEAN,
      
        allowNull: false,
        defaultValue: false,
      
      

      },

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

  weather_states.associate = (db) => {


/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity



































    db.weather_states.hasMany(db.world_calendar_days, {
      as: 'world_calendar_days_weather_state',
      foreignKey: {
          name: 'weather_stateId',
      },
      constraints: false,
    });

















//end loop






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

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



  return weather_states;
};


