add pet
This commit is contained in:
parent
3772d7b023
commit
99908c6a5a
2 changed files with 22 additions and 8 deletions
|
|
@ -1,16 +1,14 @@
|
|||
from typing import Optional
|
||||
from typing import Optional, TYPE_CHECKING
|
||||
|
||||
from sqlmodel import Field
|
||||
from sqlmodel import Field, Relationship
|
||||
|
||||
from learn_sql_model.models.fast_model import FastModel
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from learn_sql_model.models.hero import Hero
|
||||
|
||||
|
||||
class Pet(FastModel, table=True):
|
||||
id: Optional[int] = Field(default=None, primary_key=True)
|
||||
name: str = "Jim"
|
||||
|
||||
|
||||
# age: Optional[int] = None
|
||||
|
||||
# hero_id: int = Field(default=None, foreign_key="hero.id")
|
||||
# hero: Optional[Hero] = Relationship(back_populates="pets")
|
||||
hero: "Hero" = Relationship(back_populates="pet")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue