Coverage for docs_src/tutorial/code_structure/tutorial001_py39/models.py: 100%
14 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 Optional 1abcd
3from sqlmodel import Field, Relationship, SQLModel 1abcd
6class Team(SQLModel, table=True): 1abcd
7 id: Optional[int] = Field(default=None, primary_key=True) 1abcd
8 name: str = Field(index=True) 1abcd
9 headquarters: str 1abcd
11 heroes: list["Hero"] = Relationship(back_populates="team") 1abcd
14class Hero(SQLModel, table=True): 1abcd
15 id: Optional[int] = Field(default=None, primary_key=True) 1abcd
16 name: str = Field(index=True) 1abcd
17 secret_name: str 1abcd
18 age: Optional[int] = Field(default=None, index=True) 1abcd
20 team_id: Optional[int] = Field(default=None, foreign_key="team.id") 1abcd
21 team: Optional[Team] = Relationship(back_populates="heroes") 1abcd