Browse Source

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

ogert 4 years ago
parent
commit
6e3e9c3322
1 changed files with 4 additions and 0 deletions
  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))