This commit is contained in:
Waylon Walker 2025-11-22 21:59:30 -06:00
parent cd33982985
commit 9d6d509618
3 changed files with 106 additions and 35 deletions

View file

@ -9,8 +9,7 @@ from sqlmodel_base.base import Base
console = Console()
class Hero(Base, table=True):
id: Optional[int] = Field(default=None, primary_key=True)
class HeroBase(Base):
name: str
secret_name: str
age: Optional[int] = None
@ -23,3 +22,29 @@ class Hero(Base, table=True):
if v > 0:
return v
return abs(v)
class Hero(HeroBase, table=True):
id: Optional[int] = Field(default=None, primary_key=True)
class HeroCreate(HeroBase):
__table_class__ = Hero
pass
class HeroRead(HeroBase):
__table_class__ = Hero
id: int
class HeroUpdate(Base, table=False):
__table_class__ = Hero
name: Optional[str]
secret_name: Optional[str]
age: Optional[int]
team_id: Optional[int]
if __name__ == "__main__":
Hero.cli()