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

status: {
        type: DataTypes.ENUM,
      
      

        values: [

"requested",


"accepted",


"blocked"

        ],

      },

requested_at: {
        type: DataTypes.DATE,
      
      

      },

accepted_at: {
        type: DataTypes.DATE,
      
      

      },

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

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

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




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

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



  return follows;
};


