From 71565f47945a93c69312ec6963941984fdfa88e8 Mon Sep 17 00:00:00 2001 From: yangdx Date: Thu, 26 Jun 2025 13:51:15 +0800 Subject: [PATCH] Add get_all method to MongoKVStorage --- lightrag/kg/mongo_impl.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lightrag/kg/mongo_impl.py b/lightrag/kg/mongo_impl.py index 109ba59d..6be02d1d 100644 --- a/lightrag/kg/mongo_impl.py +++ b/lightrag/kg/mongo_impl.py @@ -107,6 +107,19 @@ class MongoKVStorage(BaseKVStorage): existing_ids = {str(x["_id"]) async for x in cursor} return keys - existing_ids + async def get_all(self) -> dict[str, Any]: + """Get all data from storage + + Returns: + Dictionary containing all stored data + """ + cursor = self._data.find({}) + result = {} + async for doc in cursor: + doc_id = doc.pop("_id") + result[doc_id] = doc + return result + async def upsert(self, data: dict[str, dict[str, Any]]) -> None: logger.info(f"Inserting {len(data)} to {self.namespace}") if not data: