2024-08-11 20:21:54 +02:00
|
|
|
from sqlmodel import Field, SQLModel, Relationship
|
|
|
|
|
|
2024-08-02 12:48:35 +02:00
|
|
|
from typing import Union
|
2024-08-02 11:43:30 +02:00
|
|
|
from datetime import date
|
|
|
|
|
|
2024-08-11 20:21:54 +02:00
|
|
|
class PlayPlayer(SQLModel, table=True):
|
2024-08-11 21:27:59 +02:00
|
|
|
id: int | None = Field(default=None, primary_key=True)
|
|
|
|
|
name: str
|
2024-08-02 11:43:30 +02:00
|
|
|
username: str
|
2024-08-02 12:48:35 +02:00
|
|
|
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
|
|
|
|
2024-08-11 21:27:59 +02:00
|
|
|
play_id : int = Field(default=None, foreign_key="play.id")
|
|
|
|
|
play: "Play" = Relationship(back_populates="players")
|
2024-08-11 20:21:54 +02:00
|
|
|
|
|
|
|
|
class Play(SQLModel, table=True):
|
2024-08-11 21:27:59 +02:00
|
|
|
id: int | None = Field(default=None, primary_key=True)
|
2024-08-02 11:43:30 +02:00
|
|
|
boardgame_id: int
|
2024-08-02 12:48:35 +02:00
|
|
|
play_date: date
|
2024-08-02 11:43:30 +02:00
|
|
|
duration: int #In minutes
|
|
|
|
|
ignore_for_stats : bool
|
2024-08-11 20:21:54 +02:00
|
|
|
location: str
|
|
|
|
|
|
2024-08-11 21:27:59 +02:00
|
|
|
players: list[PlayPlayer] = Relationship(back_populates="play")
|