mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
feat(FastAPI): add aurweb.db.delete_all(iterable)
Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
c8d01cc5e8
commit
ed68fa2b57
1 changed files with 8 additions and 0 deletions
|
@ -2,6 +2,8 @@ import functools
|
||||||
import math
|
import math
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
from typing import Iterable
|
||||||
|
|
||||||
from sqlalchemy import event
|
from sqlalchemy import event
|
||||||
from sqlalchemy.orm import scoped_session
|
from sqlalchemy.orm import scoped_session
|
||||||
|
|
||||||
|
@ -71,6 +73,12 @@ def delete(model, *args, **kwargs):
|
||||||
session.delete(record)
|
session.delete(record)
|
||||||
|
|
||||||
|
|
||||||
|
def delete_all(iterable: Iterable):
|
||||||
|
with begin():
|
||||||
|
for obj in iterable:
|
||||||
|
session.delete(obj)
|
||||||
|
|
||||||
|
|
||||||
def rollback():
|
def rollback():
|
||||||
session.rollback()
|
session.rollback()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue