Add debug statement
This commit is contained in:
@@ -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)):
|
||||
|
||||
Reference in New Issue
Block a user