16 lines
546 B
Python
16 lines
546 B
Python
from sqlalchemy import ForeignKey, Integer
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from fooder.domain.base import Base, AggregateMacrosMixin, CommonMixin
|
|
from fooder.domain.entry import Entry
|
|
|
|
|
|
class Meal(Base, CommonMixin, AggregateMacrosMixin):
|
|
"""Meal."""
|
|
|
|
name: Mapped[str]
|
|
order: Mapped[int]
|
|
diary_id: Mapped[int] = mapped_column(Integer, ForeignKey("diary.id"))
|
|
entries: Mapped[list[Entry]] = relationship(
|
|
lazy="selectin", order_by=Entry.last_changed, cascade="all, delete-orphan"
|
|
)
|