from sqlmodel import Field, Relationship, SQLModel
from typing import Optional
from app.models.base_uuid_model import BaseUUIDModel
from uuid import UUID

class HeroBase(SQLModel):
    name: str = Field(index=True)
    secret_name: str
    age: Optional[int] = Field(default=None, index=True)
    team_id: Optional[UUID] = Field(default=None, foreign_key="team.id")

class Hero(BaseUUIDModel, HeroBase, table=True):    
    team: Optional["Team"] = Relationship(back_populates="heroes", sa_relationship_kwargs={"lazy": "selectin"})
    created_by_id: Optional[UUID] = Field(default=None, foreign_key="user.id")
    created_by: "User" = Relationship(sa_relationship_kwargs={"lazy":"selectin", "primaryjoin":"Hero.created_by_id==User.id"})
    
sqlmodel.Field sqlmodel.Relationship
[((197, 214), 'sqlmodel.Field', 'Field', ([], {'index': '(True)'}), '(index=True)\n', (202, 214), False, 'from sqlmodel import Field, Relationship, SQLModel\n'), ((261, 292), 'sqlmodel.Field', 'Field', ([], {'default': 'None', 'index': '(True)'}), '(default=None, index=True)\n', (266, 292), False, 'from sqlmodel import Field, Relationship, SQLModel\n'), ((323, 365), 'sqlmodel.Field', 'Field', ([], {'default': 'None', 'foreign_key': '"""team.id"""'}), "(default=None, foreign_key='team.id')\n", (328, 365), False, 'from sqlmodel import Field, Relationship, SQLModel\n'), ((449, 535), 'sqlmodel.Relationship', 'Relationship', ([], {'back_populates': '"""heroes"""', 'sa_relationship_kwargs': "{'lazy': 'selectin'}"}), "(back_populates='heroes', sa_relationship_kwargs={'lazy':\n    'selectin'})\n", (461, 535), False, 'from sqlmodel import Field, Relationship, SQLModel\n'), ((568, 610), 'sqlmodel.Field', 'Field', ([], {'default': 'None', 'foreign_key': '"""user.id"""'}), "(default=None, foreign_key='user.id')\n", (573, 610), False, 'from sqlmodel import Field, Relationship, SQLModel\n'), ((636, 743), 'sqlmodel.Relationship', 'Relationship', ([], {'sa_relationship_kwargs': "{'lazy': 'selectin', 'primaryjoin': 'Hero.created_by_id==User.id'}"}), "(sa_relationship_kwargs={'lazy': 'selectin', 'primaryjoin':\n    'Hero.created_by_id==User.id'})\n", (648, 743), False, 'from sqlmodel import Field, Relationship, SQLModel\n')]