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

title: {
        type: DataTypes.TEXT,
      
      

      },

summary: {
        type: DataTypes.TEXT,
      
      

      },

topic_type: {
        type: DataTypes.ENUM,
      
      

        values: [

"greeting",


"small_talk",


"quest",


"festival",


"market",


"relationship",


"tutorial",


"reaction"

        ],

      },

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

      },

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

  dialogue_topics.associate = (db) => {


/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity

















    db.dialogue_topics.hasMany(db.dialogue_lines, {
      as: 'dialogue_lines_topic',
      foreignKey: {
          name: 'topicId',
      },
      constraints: false,
    });



































//end loop






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

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



  return dialogue_topics;
};


