Skip to content

User Model

This model is used to store user information.

Bases: Base

User model

Source code in FasterAPI\models.py
class User(Base):
    """User model"""

    __tablename__ = "users"
    id: Mapped[int] = mapped_column(primary_key=True, index=True)
    username: Mapped[str] = mapped_column(unique=True, index=True)
    first_name: Mapped[str]
    last_name: Mapped[str]
    email: Mapped[str]
    hashed_password: Mapped[str]
    is_superuser: Mapped[bool]
    privileges: Mapped[List["UserPrivilege"]] = relationship(
        back_populates="user", cascade="all,delete"
    )
    session: Mapped["ActiveSession"] = relationship(
        back_populates="user", cascade="all,delete"
    )

__tablename__ = 'users' class-attribute instance-attribute

email: Mapped[str] instance-attribute

first_name: Mapped[str] instance-attribute

hashed_password: Mapped[str] instance-attribute

id: Mapped[int] = mapped_column(primary_key=True, index=True) class-attribute instance-attribute

is_superuser: Mapped[bool] instance-attribute

last_name: Mapped[str] instance-attribute

privileges: Mapped[List[UserPrivilege]] = relationship(back_populates='user', cascade='all,delete') class-attribute instance-attribute

session: Mapped[ActiveSession] = relationship(back_populates='user', cascade='all,delete') class-attribute instance-attribute

username: Mapped[str] = mapped_column(unique=True, index=True) class-attribute instance-attribute