Adding top-level Scopes table
This commit is contained in:
1 parent
bc8b67d585
commit
3febc15a8f
11 files changed
+470
-1
No files matched your search
@@ -31,6 +31,30 @@ async def list_all(
|
||||
return list(result.scalars().all())
|
||||
|
||||
|
||||
async def list_by_part_type(
|
||||
db: AsyncSession, part_type_id: int, skip: int = 0, limit: int = 1000
|
||||
) -> list[AugmentedPart]:
|
||||
"""All augmented parts of a given part type, ordered by description."""
|
||||
result = await db.execute(
|
||||
select(AugmentedPart)
|
||||
.where(AugmentedPart.part_type_id == part_type_id)
|
||||
.order_by(AugmentedPart.description)
|
||||
.offset(skip)
|
||||
.limit(limit)
|
||||
)
|
||||
return list(result.scalars().all())
|
||||
|
||||
|
||||
async def get_many(db: AsyncSession, ids: list[int]) -> list[AugmentedPart]:
|
||||
"""Fetch augmented parts by id in one query (selectin relationships loaded)."""
|
||||
if not ids:
|
||||
return []
|
||||
result = await db.execute(
|
||||
select(AugmentedPart).where(AugmentedPart.id.in_(ids))
|
||||
)
|
||||
return list(result.scalars().all())
|
||||
|
||||
|
||||
async def list_filtered(
|
||||
db: AsyncSession,
|
||||
description: str = "",
|
||||
|
||||
Reference in new issue
Block a user