25 lines
No EOL
708 B
Python
25 lines
No EOL
708 B
Python
from sqlmodel import Field, SQLModel, Relationship
|
|
|
|
from typing import Union
|
|
from datetime import date
|
|
|
|
class PlayPlayer(SQLModel, table=True):
|
|
id: int | None = Field(default=None, primary_key=True)
|
|
name: str
|
|
username: str
|
|
score: Union[float, None]
|
|
first_play : bool
|
|
has_won : bool
|
|
|
|
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)
|
|
boardgame_id: int
|
|
play_date: date
|
|
duration: int #In minutes
|
|
ignore_for_stats : bool
|
|
location: str
|
|
|
|
players: list[PlayPlayer] = Relationship(back_populates="play") |