20 lines
691 B
Python
20 lines
691 B
Python
from sqlalchemy import select
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from models import AttributeSelect, AttributeOption
|
|
from repositories.base import BaseRepository
|
|
from repositories.mixins import RepGetAllMixin
|
|
|
|
|
|
class AttrSelectRepository(BaseRepository, RepGetAllMixin[AttributeSelect]):
|
|
session: AsyncSession
|
|
entity_class = AttributeSelect
|
|
|
|
async def get_options(self, select_id: int) -> list[AttributeOption]:
|
|
stmt = select(AttributeOption).where(
|
|
AttributeOption.select_id == select_id,
|
|
AttributeOption.is_deleted.is_(False),
|
|
)
|
|
result = await self.session.execute(stmt)
|
|
return list(result.scalars().all())
|