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

min_age: {
        type: DataTypes.INTEGER,
      
      

      },

max_age: {
        type: DataTypes.INTEGER,
      
      

      },

max_distance_km: {
        type: DataTypes.INTEGER,
      
      

      },

min_height_cm: {
        type: DataTypes.INTEGER,
      
      

      },

max_height_cm: {
        type: DataTypes.INTEGER,
      
      

      },

dating_intention: {
        type: DataTypes.ENUM,
      
      

        values: [

"chat",


"casual",


"relationship",


"marriage",


"friends",


"not_sure"

        ],

      },

preferred_gender: {
        type: DataTypes.ENUM,
      
      

        values: [

"women",


"men",


"everyone"

        ],

      },

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

      },

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

      },

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

      },

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

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




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

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



  return discovery_preferences;
};


