This commit is contained in:
retoor 2025-06-01 03:38:12 +02:00
parent 69855fa118
commit e0255b28ec
2 changed files with 7 additions and 0 deletions
src/snek/system

View File

@ -74,6 +74,10 @@ class BaseMapper:
for record in await self.run_in_executor(self.db.query,sql, *args):
yield dict(record)
async def update(self, model):
model.updated_at.update()
return await self.run_in_executor(self.table.update, model.record, ["uid"])
async def delete(self, **kwargs) -> int:
if not kwargs or not isinstance(kwargs, dict):
raise Exception("Can't execute delete with no filter.")

View File

@ -26,6 +26,9 @@ class BaseService:
kwargs["uid"] = uid
return await self.count(**kwargs) > 0
async def update(self, model):
return await self.mapper.update(model)
async def count(self, **kwargs):
return await self.mapper.count(**kwargs)