Existing extra fields for entities are now cleared if a field is deleted

This commit is contained in:
Donkie
2024-01-06 20:08:39 +01:00
parent 86e126f775
commit 09b8705133
4 changed files with 36 additions and 0 deletions

View File

@@ -200,6 +200,13 @@ async def delete(db: AsyncSession, spool_id: int) -> None:
await spool_changed(spool, EventType.DELETED)
async def clear_extra_field(db: AsyncSession, key: str) -> None:
"""Delete all extra fields with a specific key."""
await db.execute(
sqlalchemy.delete(models.SpoolField).where(models.SpoolField.key == key),
)
async def use_weight_safe(db: AsyncSession, spool_id: int, weight: float) -> None:
"""Consume filament from a spool by weight in a way that is safe against race conditions.