import { IFoodItem } from "./foodItem";
import mongoose, { model, Schema, Model, Document } from "mongoose";
import { MealOptions } from "../controller/trackingController";
import mongooseDateonly from "mongoose-dateonly";
const DateOnly = mongooseDateonly(mongoose);

export interface IFoodTracking extends Document {
  username: string;
  fooditem: IFoodItem;
  date: Date;
  mealOption: MealOptions;
  amount: number;
}

const FoodTrackingSchema: Schema = new Schema({
  username: { type: String, required: true, unique: false },
  date: { type: DateOnly },
  mealOption: { type: String, enum: MealOptions },
  amount: { type: Number },
  fooditem: {
    type: mongoose.Schema.Types.ObjectId,
    ref: "fooditem",
  },
});

export const FoodTracking: Model<IFoodTracking> = model(
  "foodtracking",
  FoodTrackingSchema
);
