from pydantic.types import List, Optional
from sqlmodel import Field, Relationship, SQLModel


class TeamBase(SQLModel):
    name: str
    headquarters: str

    class Config:
        schema_extra = {
            "example": {
                "name": "wonderful league",
                "headquarters": "Fortress of Solitude",
            }
        }


class Team(TeamBase, table=True):
    id: Optional[int] = Field(default=None, primary_key=True)

    heroes: List["Hero"] = Relationship(back_populates="team")


class TeamCreate(TeamBase):
    pass


class TeamRead(TeamBase):
    id: int


class TeamUpdate(TeamBase):
    name: Optional[str] = None
    headquarters: Optional[str] = None

sqlmodel.Field sqlmodel.Relationship
[((410, 447), 'sqlmodel.Field', 'Field', ([], {'default': 'None', 'primary_key': '(True)'}), '(default=None, primary_key=True)\n', (415, 447), False, 'from sqlmodel import Field, Relationship, SQLModel\n'), ((476, 511), 'sqlmodel.Relationship', 'Relationship', ([], {'back_populates': '"""team"""'}), "(back_populates='team')\n", (488, 511), False, 'from sqlmodel import Field, Relationship, SQLModel\n')]