fooder-api/fooder/model/entry.py

29 lines
553 B
Python

from typing import Annotated
from pydantic import BaseModel, Field
from fooder.model.base import ObjModelMixin
from fooder.model.product import ProductModel
Grams = Annotated[float, Field(gt=0)]
class EntryModel(ObjModelMixin, BaseModel):
grams: Grams
product_id: int
meal_id: int
product: ProductModel
protein: float
carb: float
fat: float
fiber: float
calories: float
class EntryCreateModel(BaseModel):
grams: Grams
product_id: int
class EntryUpdateModel(BaseModel):
grams: Grams | None = None