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

day_of_week: {
        type: DataTypes.ENUM,
      
      

        values: [

"monday",


"tuesday",


"wednesday",


"thursday",


"friday",


"saturday",


"sunday"

        ],

      },

open_time: {
        type: DataTypes.TEXT,
      
      

      },

close_time: {
        type: DataTypes.TEXT,
      
      

      },

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

      },

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

      },

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

  place_opening_hours.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.place_opening_hours.belongsTo(db.places, {
      as: 'place',
      foreignKey: {
        name: 'placeId',
      },
      constraints: false,
    });




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

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



  return place_opening_hours;
};


