Prechádzať zdrojové kódy

add functin get_distinct_values_from_key to MongoHandler

tsteuer 4 rokov pred
rodič
commit
650ba4f52b
1 zmenil súbory, kde vykonal 12 pridanie a 0 odobranie
  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]
         else:
             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__":