Pārlūkot izejas kodu

added collection count method to mongohandler

tsteuer 4 gadi atpakaļ
vecāks
revīzija
002ce6acfa
1 mainītis faili ar 9 papildinājumiem un 0 dzēšanām
  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__":