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

full_name: {
        type: DataTypes.TEXT,
      
      

      },

email: {
        type: DataTypes.TEXT,
      
      

      },

phone: {
        type: DataTypes.TEXT,
      
      

      },

rsvp_status: {
        type: DataTypes.ENUM,
      
      

        values: [

"invited",


"confirmed",


"declined",


"waitlisted",


"checked_in"

        ],

      },

guest_type: {
        type: DataTypes.ENUM,
      
      

        values: [

"vip",


"regular",


"staff",


"vendor_rep",


"speaker"

        ],

      },

invited_at: {
        type: DataTypes.DATE,
      
      

      },

checked_in_at: {
        type: DataTypes.DATE,
      
      

      },

notes: {
        type: DataTypes.TEXT,
      
      

      },

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

  event_guests.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.event_guests.belongsTo(db.events, {
      as: 'event',
      foreignKey: {
        name: 'eventId',
      },
      constraints: false,
    });

    db.event_guests.belongsTo(db.organizations, {
      as: 'organizations',
      foreignKey: {
        name: 'organizationsId',
      },
      constraints: false,
    });




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

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



  return event_guests;
};


