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

name: {
        type: DataTypes.TEXT,
      
      

      },

category: {
        type: DataTypes.ENUM,
      
      

        values: [

"educational_environmental",


"museums_culture",


"stem_learning",


"fun_recreation",


"movies",


"zoo",


"premium"

        ],

      },

location_name: {
        type: DataTypes.TEXT,
      
      

      },

grade_range: {
        type: DataTypes.TEXT,
      
      

      },

typical_min_rate: {
        type: DataTypes.DECIMAL,
      
      

      },

typical_max_rate: {
        type: DataTypes.DECIMAL,
      
      

      },

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

      },

notes: {
        type: DataTypes.TEXT,
      
      

      },

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

  field_trip_catalog.associate = (db) => {


/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity


















    db.field_trip_catalog.hasMany(db.field_trip_events, {
      as: 'field_trip_events_field_trip',
      foreignKey: {
          name: 'field_tripId',
      },
      constraints: false,
    });











//end loop






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

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



  return field_trip_catalog;
};


