Update for filters.
All checks were successful
Build Base Application / Build (push) Successful in 1m37s

This commit is contained in:
retoor 2024-12-11 19:41:38 +01:00
parent eb5af2ab7b
commit 249e44f405

View File

@ -177,7 +177,8 @@ class WebDbApplication(BaseApplication):
async def get(self, key, default=None):
record = self.db["kv"].find_one(key=key)
if record:
return json.loads(record.get("value", "null"))
result = record.get("value","null")
return result == "null" and default or json.loads(result)
return default
async def insert(self, table_name, data):
@ -189,12 +190,12 @@ class WebDbApplication(BaseApplication):
async def upsert(self, table_name, data, keys):
return self.db[table_name].upsert(data, keys or [])
async def find(self, table_name, filters):
async def find(self, table_name, filters=None):
if not filters:
filters = {}
return [dict(record) for record in self.db[table_name].find(**filters)]
async def find_one(self, table_name, filters):
async def find_one(self, table_name, filters=None):
if not filters:
filters = {}
try: