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

line_text: {
        type: DataTypes.TEXT,
      
      

      },

mood_tag: {
        type: DataTypes.ENUM,
      
      

        values: [

"neutral",


"happy",


"sad",


"angry",


"funny",


"romantic",


"serious"

        ],

      },

priority: {
        type: DataTypes.INTEGER,
      
      

      },

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

  dialogue_lines.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.dialogue_lines.belongsTo(db.dialogue_topics, {
      as: 'topic',
      foreignKey: {
        name: 'topicId',
      },
      constraints: false,
    });

    db.dialogue_lines.belongsTo(db.npcs, {
      as: 'npc',
      foreignKey: {
        name: 'npcId',
      },
      constraints: false,
    });



    db.dialogue_lines.hasMany(db.file, {
      as: 'voice_files',
      foreignKey: 'belongsToId',
      constraints: false,
      scope: {
        belongsTo: db.dialogue_lines.getTableName(),
        belongsToColumn: 'voice_files',
      },
    });


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

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



  return dialogue_lines;
};


