text: module.exports = (sequelize, DataTypes) => {
      const Record = sequelize.define("Record", {
          amount: {
              type: DataTypes.FLOAT,
              allowNull: false
          }
      })
  
      Record.associate = (models) => {
          Record.belongsTo(models.Food, {as: 'food'});
      }
  
      Record.add = async function(record) {
          return await Record.create(record);
      }
  
      Record.get = async function(condition) {
          if (Number.isInteger(condition))
              condition = { id: condition };
  
          const records = await Record.findAll({ where: condition });
          if (!records)
              throw Error(`There are no any records with condition='${JSON.stringify(condition)}'.`)
          return records;
      }
  
      Record.modify = async function(record, condition) {
          if (Number.isInteger(condition))
              condition = { id: condition };
  
          const count = await Record.update(record, { where: condition });
          if (count == 0)
              throw Error(`There are no any records with condition='${JSON.stringify(condition)}'.`);
          return count;
      }
  
      Record.delete = async function(condition) {
          if (Number.isInteger(condition))
              condition = { id: condition };
  
          const count = await Record.destroy({ where: condition, truncate: false });
          if (count == 0)
              throw Error(`There are no any records with condition='${JSON.stringify(condition)}'.`);
          return count;
      }
  
      return Record;
  }
  
  
  /*
  module.exports = (db) => {
      const Sequelize = db.Sequelize;
      const sequelize = db.sequelize;
      const Food = db.food;
  
      const Records = sequelize.define("record", {
          amount: {
              type: Sequelize.FLOAT,
              allowNull: false
          },
          time: {
              type: Sequelize.DATEONLY,
              allowNull: false
          }
      });
  
      Records.add = (record) => {
          return Records.create(record)
              .then(record => {
                  return record;
              })
      }
  
      Records.get = (condition) => {
          if (Number.isInteger(condition))
              condition = { id: condition };
          return Records.findAll({
                  where: condition,
                  attributes: { exclude: ['foodId'] },
                  include: {
                      model: Food,
                      as: "food"
                  }
              })
              .then(records => {
                  if (!records)
                      throw Error(`There are no any records with condition='${condition}'.`)
                  return records;
              })
  
      }
  
      Records.modify = (record, condition) => {
          if (Number.isInteger(condition))
              condition = { id: condition };
          return Records.update(record, { where: condition })
              .then(num => {
                  if (num == 0)
                      throw Error(`There are no any records with condition='${condition}'.`);
                  return num;
              })
      }
  
      Records.delete = (condition) => {
          if (Number.isInteger(condition))
              condition = { id: condition };
          return Records.destroy({ where: condition, truncate: false })
              .then(num => {
                  return num;
              })
      }
  
      return Records;
  };
  
  */