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

nickname: {
        type: DataTypes.TEXT,
      
      

      },

bio: {
        type: DataTypes.TEXT,
      
      

      },

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

      },

xp_coins_balance: {
        type: DataTypes.INTEGER,
      
      

      },

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

      },

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

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

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




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

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



  return fan_profiles;
};


