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

page_key: {
        type: DataTypes.ENUM,
      
      

        values: [

"home",


"products",


"product_detail",


"projects",


"project_detail",


"services",


"service_detail",


"about",


"contact",


"blog",


"post_detail",


"privacy",


"terms"

        ],

      },

title_ar: {
        type: DataTypes.TEXT,
      
      

      },

description_ar: {
        type: DataTypes.TEXT,
      
      

      },

canonical_url: {
        type: DataTypes.TEXT,
      
      

      },

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

      },

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

  seo_pages.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.seo_pages.hasMany(db.file, {
      as: 'structured_data_jsonld',
      foreignKey: 'belongsToId',
      constraints: false,
      scope: {
        belongsTo: db.seo_pages.getTableName(),
        belongsToColumn: 'structured_data_jsonld',
      },
    });


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

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



  return seo_pages;
};


