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

content_type: {
        type: DataTypes.ENUM,
      
      

        values: [

"post",


"story",


"reel",


"profile"

        ],

      },

content_ref: {
        type: DataTypes.TEXT,
      
      

      },

window_start_at: {
        type: DataTypes.DATE,
      
      

      },

window_end_at: {
        type: DataTypes.DATE,
      
      

      },

impressions: {
        type: DataTypes.INTEGER,
      
      

      },

reach: {
        type: DataTypes.INTEGER,
      
      

      },

profile_visits: {
        type: DataTypes.INTEGER,
      
      

      },

likes: {
        type: DataTypes.INTEGER,
      
      

      },

comments: {
        type: DataTypes.INTEGER,
      
      

      },

saves: {
        type: DataTypes.INTEGER,
      
      

      },

shares: {
        type: DataTypes.INTEGER,
      
      

      },

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

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




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

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



  return insight_snapshots;
};


