core (memory/sqla): generic methods to add and delete ORM objects directly
This commit is contained in:
parent
85ea69c3c3
commit
53a77a4c71
1 changed files with 17 additions and 0 deletions
|
|
@ -186,6 +186,23 @@ class Storage:
|
|||
|
||||
self.initialized.callback(None)
|
||||
|
||||
## Generic
|
||||
|
||||
@aio
|
||||
async def add(self, db_obj: DeclarativeMeta) -> None:
|
||||
"""Add an object to database"""
|
||||
async with self.session() as session:
|
||||
async with session.begin():
|
||||
session.add(db_obj)
|
||||
|
||||
@aio
|
||||
async def delete(self, db_obj: DeclarativeMeta) -> None:
|
||||
"""Delete an object from database"""
|
||||
async with self.session() as session:
|
||||
async with session.begin():
|
||||
await session.delete(db_obj)
|
||||
await session.commit()
|
||||
|
||||
## Profiles
|
||||
|
||||
def getProfilesList(self) -> List[str]:
|
||||
|
|
|
|||
Loading…
Reference in a new issue