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

emoji: {
        type: DataTypes.TEXT,
      
      

      },

reacted_at: {
        type: DataTypes.DATE,
      
      

      },

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

  comment_reactions.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.comment_reactions.belongsTo(db.comments, {
      as: 'comment',
      foreignKey: {
        name: 'commentId',
      },
      constraints: false,
    });

    db.comment_reactions.belongsTo(db.users, {
      as: 'user',
      foreignKey: {
        name: 'userId',
      },
      constraints: false,
    });

    db.comment_reactions.belongsTo(db.organizations, {
      as: 'organizations',
      foreignKey: {
        name: 'organizationsId',
      },
      constraints: false,
    });




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

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



  return comment_reactions;
};


