Add delete support for MongoKVStorage
This commit is contained in:
@@ -150,6 +150,21 @@ class MongoKVStorage(BaseKVStorage):
|
|||||||
# Mongo handles persistence automatically
|
# Mongo handles persistence automatically
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
async def delete(self, ids: list[str]) -> None:
|
||||||
|
"""Delete documents with specified IDs
|
||||||
|
|
||||||
|
Args:
|
||||||
|
ids: List of document IDs to be deleted
|
||||||
|
"""
|
||||||
|
if not ids:
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
result = await self._data.delete_many({"_id": {"$in": ids}})
|
||||||
|
logger.info(f"Deleted {result.deleted_count} documents from {self.namespace}")
|
||||||
|
except PyMongoError as e:
|
||||||
|
logger.error(f"Error deleting documents from {self.namespace}: {e}")
|
||||||
|
|
||||||
async def drop(self) -> dict[str, str]:
|
async def drop(self) -> dict[str, str]:
|
||||||
"""Drop the storage by removing all documents in the collection.
|
"""Drop the storage by removing all documents in the collection.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user