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

rank: {
        type: DataTypes.INTEGER,
      
      

      },

reason: {
        type: DataTypes.TEXT,
      
      

      },

shown_at: {
        type: DataTypes.DATE,
      
      

      },

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

  daily_spark_recommendations.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.daily_spark_recommendations.belongsTo(db.daily_sparks, {
      as: 'daily_spark',
      foreignKey: {
        name: 'daily_sparkId',
      },
      constraints: false,
    });

    db.daily_spark_recommendations.belongsTo(db.users, {
      as: 'recommended_user',
      foreignKey: {
        name: 'recommended_userId',
      },
      constraints: false,
    });




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

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



  return daily_spark_recommendations;
};


