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

status: {
        type: DataTypes.ENUM,
      
      

        values: [

"active",


"requested",


"blocked",


"muted"

        ],

      },

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

      },

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

  user_relationships.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.user_relationships.belongsTo(db.users, {
      as: 'follower',
      foreignKey: {
        name: 'followerId',
      },
      constraints: false,
    });

    db.user_relationships.belongsTo(db.users, {
      as: 'following',
      foreignKey: {
        name: 'followingId',
      },
      constraints: false,
    });




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

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



  return user_relationships;
};


