refactors

This commit is contained in:
counterweight 2025-12-25 18:27:59 +01:00
parent f46d2ae8b3
commit 168b67acee
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
12 changed files with 471 additions and 126 deletions

View file

@ -0,0 +1,18 @@
"""Role repository for database queries."""
from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession
from models import Role
class RoleRepository:
"""Repository for role-related database queries."""
def __init__(self, db: AsyncSession):
self.db = db
async def get_by_name(self, name: str) -> Role | None:
"""Get a role by name."""
result = await self.db.execute(select(Role).where(Role.name == name))
return result.scalar_one_or_none()