renamed module

This commit is contained in:
brian
2024-10-20 20:00:13 +00:00
parent d1ee43e135
commit e2338ad710
26 changed files with 63 additions and 82 deletions
+20
View File
@@ -0,0 +1,20 @@
"""Definition of function to count documents in database."""
from __future__ import annotations
from pymongo.collection import Collection
def count_documents(
collection: Collection,
only_with_annotation: bool = False,
) -> int:
"""Get the total number of documents in database that matches the
filters."""
assert isinstance(collection, Collection)
assert isinstance(only_with_annotation, bool)
# build query
query = {}
if only_with_annotation:
query['annotation'] = {'$ne': None}
return collection.count_documents(filter=query)