Filaments can now be created

This commit is contained in:
Donkie
2023-04-01 22:51:36 +02:00
parent 35fdd23ec0
commit 2fa91b0632
11 changed files with 246 additions and 44 deletions

View File

@@ -0,0 +1,14 @@
"""Helper functions for interacting with vendor database objects."""
from sqlalchemy.ext.asyncio import AsyncSession
from spoolson.database import models
from spoolson.exceptions import ItemNotFoundError
async def get_by_id(db: AsyncSession, vendor_id: int) -> models.Vendor:
"""Get a vendor object from the database by the unique ID."""
vendor = await db.get(models.Vendor, vendor_id)
if vendor is None:
raise ItemNotFoundError(f"No vendor with ID {vendor_id} found.")
return vendor