浏览代码

added collection count method to mongohandler

tsteuer 4 年之前
父节点
当前提交
002ce6acfa
共有 1 个文件被更改,包括 9 次插入0 次删除
  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__":