Skip to content

OpenRAG is a comprehensive, single package Retrieval-Augmented Generation platform built on Langflow, Docling, and Opensearch.

Python
678 B
Raw Blame
from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession
from sqlmodel import col

from db.models import Permission


class PermissionRepo:
    def __init__(self, session: AsyncSession):
        self.session = session

    async def list_all(self) -> list[Permission]:
        result = await self.session.execute(
            select(Permission).order_by(Permission.resource, Permission.action)
        )
        return list(result.scalars().all())

    async def get_by_name(self, name: str) -> Permission | None:
        result = await self.session.execute(select(Permission).where(col(Permission.name) == name))
        return result.scalar_one_or_none()