mirror of
https://github.com/wowlikon/LiB.git
synced 2026-02-04 20:34:38 +00:00
24 lines
626 B
Python
24 lines
626 B
Python
"""Модуль DB-моделей ролей"""
|
|
|
|
from typing import TYPE_CHECKING, List
|
|
|
|
from sqlmodel import Field, Relationship
|
|
|
|
from library_service.models.dto.role import RoleBase
|
|
from library_service.models.db.links import UserRoleLink
|
|
|
|
if TYPE_CHECKING:
|
|
from .user import User
|
|
|
|
|
|
class Role(RoleBase, table=True):
|
|
"""Модель роли в базе данных"""
|
|
|
|
__tablename__ = "roles"
|
|
|
|
id: int | None = Field(
|
|
default=None, primary_key=True, index=True, description="Идентификатор"
|
|
)
|
|
|
|
users: List["User"] = Relationship(back_populates="roles", link_model=UserRoleLink)
|