make a game
This commit is contained in:
parent
53d878c75a
commit
dab0697f45
4 changed files with 227 additions and 11 deletions
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue