Explorar o código

added collection count method to mongohandler

tsteuer %!s(int64=4) %!d(string=hai) anos
pai
achega
002ce6acfa
Modificáronse 1 ficheiros con 9 adicións e 0 borrados
  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__":