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

osu_beatmapset_numeric: {
        type: DataTypes.INTEGER,
      
      

      },

title: {
        type: DataTypes.TEXT,
      
      

      },

artist_name: {
        type: DataTypes.TEXT,
      
      

      },

creator_username: {
        type: DataTypes.TEXT,
      
      

      },

creator_user_numeric: {
        type: DataTypes.INTEGER,
      
      

      },

status: {
        type: DataTypes.ENUM,
      
      

        values: [

"ranked",


"loved"

        ],

      },

total_playcount: {
        type: DataTypes.INTEGER,
      
      

      },

background_image_url: {
        type: DataTypes.TEXT,
      
      

      },

cover_image_url: {
        type: DataTypes.TEXT,
      
      

      },

ranked_at: {
        type: DataTypes.DATE,
      
      

      },

loved_at: {
        type: DataTypes.DATE,
      
      

      },

last_synced_at: {
        type: DataTypes.DATE,
      
      

      },

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

  beatmap_sets.associate = (db) => {


/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity











    db.beatmap_sets.hasMany(db.beatmaps, {
      as: 'beatmaps_beatmap_set',
      foreignKey: {
          name: 'beatmap_setId',
      },
      constraints: false,
    });










//end loop






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

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



  return beatmap_sets;
};


