I told you to fuck off

This commit is contained in:
2026-01-04 12:31:05 +01:00
parent c0ff9d2328
commit 1659fb6c8b
4 changed files with 21 additions and 8 deletions

View File

@@ -3,6 +3,8 @@ import json
from pymongo import MongoClient
from pymongo.synchronous.database import Database
from src.models import logger
class MongoService:
@@ -16,19 +18,21 @@ class MongoService:
def insert(self, collection : str, data : object):
try :
logger.log_info(f"Mongo data : {data}")
collection = self._db[collection]
payload = self._to_document(data)
logger.log_info(f"Formatted data : {payload}")
result = collection.insert_one(payload)
return result.inserted_id
except Exception as e:
print(e)
logger.log_info(e)
def find(self, collection: str, field: str, value):
try :
collection = self._db[collection]
return list(collection.find({field: value}))
except Exception as e:
print(e)
logger.log_info(e)
def _to_document(self, obj):
if obj is None or isinstance(obj, (str, int, float, bool)):