From 0cde6354430ab206bf975fd8b3008933b92eea72 Mon Sep 17 00:00:00 2001 From: retoor Date: Sat, 14 Dec 2024 21:25:52 +0100 Subject: [PATCH] sget and sset --- src/app/app.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/app/app.py b/src/app/app.py index 0efe743..d2693e1 100644 --- a/src/app/app.py +++ b/src/app/app.py @@ -172,16 +172,24 @@ class WebDbApplication(BaseApplication): return web.json_response(response) async def set(self, key, value): + return self.sset(key,value) + + def sset(self, key, value): value = json.dumps(value, default=str) return self.db["kv"].upsert({"key": key, "value": value}, ["key"]) - async def get(self, key, default=None): + async def get(key,default=None): + return self.sget(key, default) + + def sget(self, key, default=None): record = self.db["kv"].find_one(key=key) if record: result = record.get("value", "null") return result == "null" and default or json.loads(result) return default + + async def insert(self, table_name, data): return self.db[table_name].insert(data)