make a game

This commit is contained in:
Waylon Walker 2023-06-10 17:48:48 -05:00
parent 53d878c75a
commit dab0697f45
No known key found for this signature in database
GPG key ID: 66E2BF2B4190EFE4
4 changed files with 227 additions and 11 deletions

View file

@ -12,6 +12,9 @@ from learn_sql_model.models.pet import Pet
class HeroBase(SQLModel, table=False):
name: str
secret_name: str
x: int
y: int
size: int
age: Optional[int] = None
shoe_size: Optional[int] = None
@ -34,6 +37,8 @@ class HeroCreate(HeroBase):
if r.status_code != 200:
raise RuntimeError(f"{r.status_code}:\n {r.text}")
return Hero.parse_obj(r.json())
class HeroRead(HeroBase):
id: int
@ -80,6 +85,8 @@ class HeroUpdate(SQLModel):
secret_name: Optional[str] = None
age: Optional[int] = None
shoe_size: Optional[int] = None
x: int
y: int
pet_id: Optional[int] = Field(default=None, foreign_key="pet.id")
pet: Optional[Pet] = Relationship(back_populates="hero")