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

occurred_at: {
        type: DataTypes.DATE,
      
      

      },

bristol_type: {
        type: DataTypes.ENUM,
      
      

        values: [

"1",


"2",


"3",


"4",


"5",


"6",


"7"

        ],

      },

color: {
        type: DataTypes.ENUM,
      
      

        values: [

"brown",


"light_brown",


"green",


"yellow",


"black",


"red",


"pale",


"other"

        ],

      },

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

      },

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

      },

associated_symptoms: {
        type: DataTypes.TEXT,
      
      

      },

notes: {
        type: DataTypes.TEXT,
      
      

      },

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

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




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

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



  return bowel_movements;
};


