bgg_api/src/classes/play_classes.py

30 lines
772 B
Python
Raw Normal View History

from sqlmodel import Field, SQLModel, Relationship
from typing import Union
2024-08-02 11:43:30 +02:00
from datetime import date
class PlayPlayer(SQLModel, table=True):
id: int | None = Field(default=None, primary_key=True)
name: str
2024-08-02 11:43:30 +02:00
username: str
score: Union[float, None]
2024-08-02 11:51:25 +02:00
first_play : bool
has_won : bool
2024-08-02 11:32:56 +02:00
play_id : int = Field(default=None, foreign_key="play.id")
play: "Play" = Relationship(back_populates="players")
class Play(SQLModel, table=True):
id: int | None = Field(default=None, primary_key=True)
2024-08-02 11:43:30 +02:00
boardgame_id: int
play_date: date
2024-08-02 11:43:30 +02:00
duration: int #In minutes
ignore_for_stats : bool
location: str
2024-08-11 21:45:27 +02:00
players: list[PlayPlayer] = Relationship(back_populates="play")
model_config = {
'validate_assignment':True
}