Skip to content

User Privilege

This model is used to store user privilege/scope. It has a many-to-one relationship with User model.

Bases: Base

User role model

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

    __tablename__ = "user_privileges"
    id: Mapped[int] = mapped_column(primary_key=True, index=True)
    user_id: Mapped[int] = mapped_column(ForeignKey("users.id"))
    privilege: Mapped[str]
    user: Mapped["User"] = relationship("User", back_populates="privileges")

__tablename__ = 'user_privileges' class-attribute instance-attribute

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

privilege: Mapped[str] instance-attribute

user: Mapped[User] = relationship('User', back_populates='privileges') class-attribute instance-attribute

user_id: Mapped[int] = mapped_column(ForeignKey('users.id')) class-attribute instance-attribute