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

logged_at: {
        type: DataTypes.DATE,
      
      

      },

bbt_c: {
        type: DataTypes.DECIMAL,
      
      

      },

cervical_mucus: {
        type: DataTypes.ENUM,
      
      

        values: [

"dry",


"sticky",


"creamy",


"watery",


"egg_white",


"other"

        ],

      },

lh_test_result: {
        type: DataTypes.ENUM,
      
      

        values: [

"negative",


"positive",


"peak",


"not_tested"

        ],

      },

cervical_position_height: {
        type: DataTypes.ENUM,
      
      

        values: [

"low",


"medium",


"high",


"unknown"

        ],

      },

cervical_position_firmness: {
        type: DataTypes.ENUM,
      
      

        values: [

"firm",


"medium",


"soft",


"unknown"

        ],

      },

cervical_position_openness: {
        type: DataTypes.ENUM,
      
      

        values: [

"closed",


"slightly_open",


"open",


"unknown"

        ],

      },

mode: {
        type: DataTypes.ENUM,
      
      

        values: [

"ttc",


"not_ttc"

        ],

      },

notes: {
        type: DataTypes.TEXT,
      
      

      },

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

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




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

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



  return fertility_logs;
};


