Przeglądaj źródła

Searching for bug

ogert 4 lat temu
rodzic
commit
c9b3587a76
1 zmienionych plików z 5 dodań i 3 usunięć
  1. 5 3
      cdplib/db_handlers/MongodbHandler.py

+ 5 - 3
cdplib/db_handlers/MongodbHandler.py

@@ -444,12 +444,14 @@ class MongodbHandler:
         try:
 
             if attribute == None or attribute_value == None:
-                data = self._database[collection_name].find({},{'_id': return_id}).sort(sort_label, direction).limit(limit)
+                query = {}
+                data = self._database[collection_name].find(query,{'_id': return_id}).sort(sort_label, direction).limit(limit)
             else:
-                data = self._database[collection_name].find({attribute: {comparison_operator: attribute_value}}, {'_id': return_id}).sort(sort_label, direction).limit(limit)
+                query = {attribute: {comparison_operator: attribute_value}}
+                data = self._database[collection_name].find(query, {'_id': return_id}).sort(sort_label, direction).limit(limit)
 
             print('THIS IS THE DATA', list(data))
-            if len(list(data)) == 0:
+            if data.collection.count_documents(query) == 0:
                 self._log.warning('No data was found for the query')
                 return None