Coverage for docs_src/tutorial/code_structure/tutorial001_py310/models.py: 100%
13 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 sqlmodel import Field, Relationship, SQLModel 1abc
4class Team(SQLModel, table=True): 1abc
5 id: int | None = Field(default=None, primary_key=True) 1abc
6 name: str = Field(index=True) 1abc
7 headquarters: str 1abc
9 heroes: list["Hero"] = Relationship(back_populates="team") 1abc
12class Hero(SQLModel, table=True): 1abc
13 id: int | None = Field(default=None, primary_key=True) 1abc
14 name: str = Field(index=True) 1abc
15 secret_name: str 1abc
16 age: int | None = Field(default=None, index=True) 1abc
18 team_id: int | None = Field(default=None, foreign_key="team.id") 1abc
19 team: Team | None = Relationship(back_populates="heroes") 1abc