Skip to content

Commit

Permalink
fix return types in db_service
Browse files Browse the repository at this point in the history
- remove and append return the document after update
  • Loading branch information
blankdots committed Nov 28, 2022
1 parent e6de52b commit 80b995b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions metadata_backend/database/db_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,14 @@ async def update_by_key_value(self, collection: str, key: str, value: str, data_
return result.acknowledged

@auto_reconnect
async def remove(self, collection: str, accession_id: str, data_to_be_removed: Union[str, Dict]) -> bool:
async def remove(self, collection: str, accession_id: str, data_to_be_removed: Union[str, Dict]) -> dict:
"""Remove element of object by its accessionId.
:param collection: Collection where document should be searched from
:param accession_id: ID of the object/submission/user to be updated
:param data_to_be_removed: str or JSON representing the data that should be
updated to removed.
:returns: True if operation was successful
:returns: JSON after remove if operaation was successful
"""
id_key = self._get_id_key(collection)
find_by_id = {id_key: accession_id}
Expand All @@ -280,7 +280,7 @@ async def remove(self, collection: str, accession_id: str, data_to_be_removed: U
find_by_id, remove_op, projection={"_id": False}, return_document=ReturnDocument.AFTER
)
LOG.debug(
"DB doc in collection: %r with data: %r removed the accesion ID: %r.",
"DB doc in collection: %r with data: %r removed the accession ID: %r.",
collection,
data_to_be_removed,
accession_id,
Expand All @@ -290,15 +290,15 @@ async def remove(self, collection: str, accession_id: str, data_to_be_removed: U
@auto_reconnect
async def append(
self, collection: str, accession_id: str, data_to_be_addded: Union[str, Dict], upsert: bool = False
) -> bool:
) -> dict:
"""Append data by to object with accessionId in collection.
:param collection: Collection where document should be searched from
:param accession_id: ID of the object/submission/user to be appended to
:param data_to_be_addded: str or JSON representing the data that should be
updated to removed.
:param upsert: If the document does not exist add it
:returns: True if operation was successful
:returns: JSON after remove if operaation was successful
"""
id_key = self._get_id_key(collection)
find_by_id = {id_key: accession_id}
Expand Down

0 comments on commit 80b995b

Please sign in to comment.