diff --git a/lightrag/kg/mongo_impl.py b/lightrag/kg/mongo_impl.py index 8a9f1f3a..d5832af0 100644 --- a/lightrag/kg/mongo_impl.py +++ b/lightrag/kg/mongo_impl.py @@ -150,6 +150,21 @@ class MongoKVStorage(BaseKVStorage): # Mongo handles persistence automatically 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]: """Drop the storage by removing all documents in the collection.