Files
fridge-tracker/app/models.py
2026-04-09 14:06:19 +01:00

28 lines
834 B
Python

from datetime import datetime
from sqlalchemy import DateTime, ForeignKey, Integer, String
from sqlalchemy.orm import Mapped, mapped_column
from .db import Base
class Drink(Base):
__tablename__ = "drinks"
id: Mapped[int] = mapped_column(Integer, primary_key=True)
name: Mapped[str] = mapped_column(String)
price: Mapped[int] = mapped_column(Integer)
stock: Mapped[int] = mapped_column(Integer)
stocked_by: Mapped[str] = mapped_column(String)
# Buys
class Transaction(Base):
__tablename__ = "transactions"
id: Mapped[int] = mapped_column(Integer, primary_key=True)
drink: Mapped[int] = mapped_column(Integer, ForeignKey(Drink.id))
user_name: Mapped[str] = mapped_column(String)
quantity: Mapped[int] = mapped_column(Integer)
timestamp: Mapped[datetime] = mapped_column(DateTime)