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

title: {
        type: DataTypes.TEXT,
      
      

      },

body: {
        type: DataTypes.TEXT,
      
      

      },

audience: {
        type: DataTypes.ENUM,
      
      

        values: [

"all",


"clients",


"freelancers"

        ],

      },

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

      },

published_at: {
        type: DataTypes.DATE,
      
      

      },

expires_at: {
        type: DataTypes.DATE,
      
      

      },

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

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

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



  return admin_announcements;
};


