Skip to content

Commit 8b0c670

Browse files
committed
Merge branch 'zd_dev'
2 parents 17e6cba + bdaea6e commit 8b0c670

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

lightrag/kg/postgres_impl.py

+30
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,36 @@ async def finalize(self):
297297
self.db = None
298298

299299
################ QUERY METHODS ################
300+
async def get_all(self) -> dict[str, Any]:
301+
"""Get all data from storage
302+
303+
Returns:
304+
Dictionary containing all stored data
305+
"""
306+
table_name = namespace_to_table_name(self.namespace)
307+
if not table_name:
308+
logger.error(f"Unknown namespace for get_all: {self.namespace}")
309+
return {}
310+
311+
sql = f"SELECT * FROM {table_name} WHERE workspace=$1"
312+
params = {"workspace": self.db.workspace}
313+
314+
try:
315+
results = await self.db.query(sql, params, multirows=True)
316+
317+
if is_namespace(self.namespace, NameSpace.KV_STORE_LLM_RESPONSE_CACHE):
318+
result_dict = {}
319+
for row in results:
320+
mode = row["mode"]
321+
if mode not in result_dict:
322+
result_dict[mode] = {}
323+
result_dict[mode][row["id"]] = row
324+
return result_dict
325+
else:
326+
return {row["id"]: row for row in results}
327+
except Exception as e:
328+
logger.error(f"Error retrieving all data from {self.namespace}: {e}")
329+
return {}
300330

301331
async def get_by_id(self, id: str) -> dict[str, Any] | None:
302332
"""Get doc_full data by id."""

0 commit comments

Comments
 (0)