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

name: {
        type: DataTypes.TEXT,
      
      

      },

breakout_key: {
        type: DataTypes.TEXT,
      
      

      },

breakout_status: {
        type: DataTypes.ENUM,
      
      

        values: [

"created",


"open",


"closed",


"archived"

        ],

      },

target_participants: {
        type: DataTypes.INTEGER,
      
      

      },

opened_at: {
        type: DataTypes.DATE,
      
      

      },

closed_at: {
        type: DataTypes.DATE,
      
      

      },

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

  breakout_rooms.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.breakout_rooms.belongsTo(db.conferences, {
      as: 'conference',
      foreignKey: {
        name: 'conferenceId',
      },
      constraints: false,
    });

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




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

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



  return breakout_rooms;
};


