Prechádzať zdrojové kódy

added collection count method to mongohandler

tsteuer 4 rokov pred
rodič
commit
002ce6acfa
1 zmenil súbory, kde vykonal 9 pridanie a 0 odobranie
  1. 9 0
      cdplib/db_handlers/MongodbHandler.py

+ 9 - 0
cdplib/db_handlers/MongodbHandler.py

@@ -540,6 +540,15 @@ class MongodbHandler:
         data = self._database[collection_name].distinct(key)
         
         return data
+    
+    def get_number_of_entries_in_collection(self, collection_name: str):
+        
+        assert(isinstance(collection_name, str)),\
+            "Parameter 'collection_name' must be a string type"
+        
+        data = self._database[collection_name].count()
+        
+        return data
 
 
 if __name__ == "__main__":