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

content: {
        type: DataTypes.TEXT,
      
      

      },

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

      },

sort_order: {
        type: DataTypes.INTEGER,
      
      

      },

feedback: {
        type: DataTypes.TEXT,
      
      

      },

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

  answer_choices.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.answer_choices.belongsTo(db.questions, {
      as: 'question',
      foreignKey: {
        name: 'questionId',
      },
      constraints: false,
    });




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

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



  return answer_choices;
};


