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

title: {
        type: DataTypes.TEXT,
      
      

      },

difficulty: {
        type: DataTypes.ENUM,
      
      

        values: [

"beginner",


"intermediate",


"advanced"

        ],

      },

topic: {
        type: DataTypes.ENUM,
      
      

        values: [

"basics",


"risk_management",


"technical_analysis",


"fundamentals",


"options_awareness",


"macro",


"portfolio_building"

        ],

      },

summary: {
        type: DataTypes.TEXT,
      
      

      },

content: {
        type: DataTypes.TEXT,
      
      

      },

estimated_minutes: {
        type: DataTypes.INTEGER,
      
      

      },

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

      },

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

  learning_modules.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.learning_modules.belongsTo(db.users, {
      as: 'createdBy',
    });

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



  return learning_modules;
};


