Quellcode durchsuchen

Add warning message for when no data for the query can be found

ogert vor 4 Jahren
Ursprung
Commit
6e3e9c3322
1 geänderte Dateien mit 4 neuen und 0 gelöschten Zeilen
  1. 4 0
      cdplib/db_handlers/MongodbHandler.py

+ 4 - 0
cdplib/db_handlers/MongodbHandler.py

@@ -387,6 +387,10 @@ class MongodbHandler:
             else:
                 data = self._database[collection_name].find({attribute: {comparison_operator: attribute_value}}, {'_id': return_id}).sort(sort_label, direction).limit(limit)
             
+            if len(list(data)) == 0:
+                self._log.warning('No data was found for the query')
+                return None
+
         except Exception as error:
             self._log.log_and_raise_error(('An error occured trying to query data from {}, \nError:{}').format(collection_name, error))