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

cache_key: {
        type: DataTypes.TEXT,
      
      

      },

cache_type: {
        type: DataTypes.ENUM,
      
      

        values: [

"redis",


"memory",


"database"

        ],

      },

namespace: {
        type: DataTypes.ENUM,
      
      

        values: [

"mapper_totals",


"artist_totals",


"game_pool",


"osu_token",


"rate_limits"

        ],

      },

expires_at: {
        type: DataTypes.DATE,
      
      

      },

refreshed_at: {
        type: DataTypes.DATE,
      
      

      },

value_hash: {
        type: DataTypes.TEXT,
      
      

      },

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

  server_caches.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.server_caches.belongsTo(db.users, {
      as: 'createdBy',
    });

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



  return server_caches;
};


