Add debug statement

This commit is contained in:
2026-01-04 12:20:30 +01:00
parent 4963db4205
commit 81c3874b04
2 changed files with 13 additions and 7 deletions

View File

@@ -15,14 +15,20 @@ class MongoService:
def insert(self, collection : str, data : object):
collection = self._db[collection]
payload = self._to_document(data)
result = collection.insert_one(payload)
return result.inserted_id
try :
collection = self._db[collection]
payload = self._to_document(data)
result = collection.insert_one(payload)
return result.inserted_id
except Exception as e:
print(e)
def find(self, collection: str, field: str, value):
col = self._db[collection]
return list(col.find({field: value}))
try :
collection = self._db[collection]
return list(collection.find({field: value}))
except Exception as e:
print(e)
def _to_document(self, obj):
if obj is None or isinstance(obj, (str, int, float, bool)):