updated function to list names of all vis com docs in database
This commit is contained in:
Regular → Executable
+7
-3
@@ -1,3 +1,7 @@
|
||||
"""
|
||||
Definition of function to list names
|
||||
of all visual communication documents in database.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from pymongo.collection import Collection
|
||||
@@ -5,14 +9,14 @@ from pymongo.collection import Collection
|
||||
|
||||
def list_names(
|
||||
collection: Collection,
|
||||
has_annotation: bool = True,
|
||||
only_with_annotation: bool = True,
|
||||
) -> list[str]:
|
||||
"""List the names of entries that match the filters."""
|
||||
assert isinstance(collection, Collection)
|
||||
assert isinstance(has_annotation, bool)
|
||||
assert isinstance(only_with_annotation, bool)
|
||||
# build query
|
||||
query = {}
|
||||
if has_annotation:
|
||||
if only_with_annotation:
|
||||
query['annotation'] = {'$ne': None}
|
||||
# execute query
|
||||
res_list = collection.find(
|
||||
|
||||
Reference in New Issue
Block a user