Adding pagination
This commit is contained in:
1 parent
a50fccd56d
commit
e923250177
8 files changed
+269
-46
No files matched your search
@@ -51,6 +51,15 @@ async def count(db: AsyncSession) -> int:
|
||||
return result.scalar_one()
|
||||
|
||||
|
||||
async def count_filtered(db: AsyncSession, description: str = "") -> int:
|
||||
from sqlalchemy import func
|
||||
q = select(func.count()).select_from(ImportedPart)
|
||||
if description.strip():
|
||||
q = q.where(ImportedPart.Description.ilike(f"%{description.strip()}%"))
|
||||
result = await db.execute(q)
|
||||
return result.scalar_one()
|
||||
|
||||
|
||||
async def delete(db: AsyncSession, part: ImportedPart) -> None:
|
||||
await db.delete(part)
|
||||
await db.commit()
|
||||
|
||||
Reference in new issue
Block a user