mirror of
https://github.com/wowlikon/LiB.git
synced 2026-02-04 04:31:09 +00:00
20 lines
568 B
Python
20 lines
568 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)
|
|
|
|
users: List["User"] = Relationship(back_populates="roles", link_model=UserRoleLink)
|