Browse Source

add functin get_distinct_values_from_key to MongoHandler

tsteuer 4 years ago
parent
commit
650ba4f52b
1 changed files with 12 additions and 0 deletions
  1. 12 0
      cdplib/db_handlers/MongodbHandler.py

+ 12 - 0
cdplib/db_handlers/MongodbHandler.py

@@ -521,6 +521,18 @@ class MongodbHandler:
             return [value[query_label] for value in data]
             return [value[query_label] for value in data]
         else:
         else:
             return []
             return []
+        
+    def get_distinct_value_of_key(self, collection_name: str, key: str):
+        
+        assert(isinstance(collection_name, str)),\
+            "Parameter 'collection_name' must be a string type"
+        
+        assert(isinstance(key, str)),\
+            "Parameter 'key' must be a string type"
+        
+        data = self._database[collection_name].distinct(key)
+        
+        return data
 
 
 
 
 if __name__ == "__main__":
 if __name__ == "__main__":