Coverage for docs_src/tutorial/code_structure/tutorial002_py39/hero_model.py: 100%
9 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-09 00:02 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-09 00:02 +0000
1from typing import TYPE_CHECKING, Optional 1abcd
3from sqlmodel import Field, Relationship, SQLModel 1abcd
5if TYPE_CHECKING: 1abcd
6 from .team_model import Team
9class Hero(SQLModel, table=True): 1abcd
10 id: Optional[int] = Field(default=None, primary_key=True) 1abcd
11 name: str = Field(index=True) 1abcd
12 secret_name: str 1abcd
13 age: Optional[int] = Field(default=None, index=True) 1abcd
15 team_id: Optional[int] = Field(default=None, foreign_key="team.id") 1abcd
16 team: Optional["Team"] = Relationship(back_populates="heroes") 1abcd