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

topic: {
        type: DataTypes.TEXT,
      
      

      },

target_question_count: {
        type: DataTypes.INTEGER,
      
      

      },

age_group: {
        type: DataTypes.ENUM,
      
      

        values: [

"early",


"kids",


"teens",


"adult",


"mixed"

        ],

      },

difficulty: {
        type: DataTypes.ENUM,
      
      

        values: [

"easy",


"medium",


"hard",


"mixed"

        ],

      },

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

      },

status: {
        type: DataTypes.ENUM,
      
      

        values: [

"collecting_requirements",


"draft_ready",


"exported_to_quiz",


"cancelled"

        ],

      },

notes: {
        type: DataTypes.TEXT,
      
      

      },

started_at: {
        type: DataTypes.DATE,
      
      

      },

finished_at: {
        type: DataTypes.DATE,
      
      

      },

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

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

    db.orbix_quiz_assistant_sessions.belongsTo(db.quizzes, {
      as: 'generated_quiz',
      foreignKey: {
        name: 'generated_quizId',
      },
      constraints: false,
    });




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

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



  return orbix_quiz_assistant_sessions;
};


