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

preference_key: {
        type: DataTypes.ENUM,
      
      

        values: [

"layout_mode",


"tile_size",


"pinned_participant",


"show_self_view",


"background_mode",


"captions_enabled",


"chat_panel_open"

        ],

      },

value: {
        type: DataTypes.TEXT,
      
      

      },

updated_at_local: {
        type: DataTypes.DATE,
      
      

      },

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

  layout_preferences.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.layout_preferences.belongsTo(db.users, {
      as: 'user',
      foreignKey: {
        name: 'userId',
      },
      constraints: false,
    });

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




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

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



  return layout_preferences;
};


