mirror of
https://github.com/fastapi/sqlmodel.git
synced 2025-08-15 02:07:54 +08:00
✨ Document indexes and make them opt-in (#205)
This commit is contained in:

committed by
GitHub

parent
3d7b74746c
commit
155c6178cd
@ -14,7 +14,7 @@ class HeroTeamLink(SQLModel, table=True):
|
||||
|
||||
class Team(SQLModel, table=True):
|
||||
id: Optional[int] = Field(default=None, primary_key=True)
|
||||
name: str
|
||||
name: str = Field(index=True)
|
||||
headquarters: str
|
||||
|
||||
heroes: List["Hero"] = Relationship(back_populates="teams", link_model=HeroTeamLink)
|
||||
@ -22,9 +22,9 @@ class Team(SQLModel, table=True):
|
||||
|
||||
class Hero(SQLModel, table=True):
|
||||
id: Optional[int] = Field(default=None, primary_key=True)
|
||||
name: str
|
||||
name: str = Field(index=True)
|
||||
secret_name: str
|
||||
age: Optional[int] = None
|
||||
age: Optional[int] = Field(default=None, index=True)
|
||||
|
||||
teams: List[Team] = Relationship(back_populates="heroes", link_model=HeroTeamLink)
|
||||
|
||||
|
Reference in New Issue
Block a user