MCPcopy Create free account
hub / github.com/InfinitiBit/graphbit / get_all_memories

Method get_all_memories

core/src/memory/store.rs:121–146  ·  view source on GitHub ↗

Get all memories matching the given scope.

(&self, scope: &MemoryScope)

Source from the content-addressed store, hash-verified

119
120 /// Get all memories matching the given scope.
121 pub async fn get_all_memories(&self, scope: &MemoryScope) -> GraphBitResult<Vec<Memory>> {
122 let user_id = scope.user_id.clone();
123 let agent_id = scope.agent_id.clone();
124 let run_id = scope.run_id.clone();
125 let conn_arc = Arc::clone(&self.conn);
126
127 tokio::task::spawn_blocking(move || -> GraphBitResult<Vec<Memory>> {
128 let conn = conn_arc.blocking_lock();
129 let (where_clause, params) = build_scope_filter(&user_id, &agent_id, &run_id);
130 let sql = format!(
131 "SELECT id, content, user_id, agent_id, run_id, hash, metadata, created_at, updated_at FROM memories{}",
132 where_clause
133 );
134 let mut stmt = conn.prepare(&sql)?;
135 let param_refs: Vec<&dyn rusqlite::types::ToSql> =
136 params.iter().map(|p| p as &dyn rusqlite::types::ToSql).collect();
137 let mut rows = stmt.query(param_refs.as_slice())?;
138 let mut memories = Vec::new();
139 while let Some(row) = rows.next()? {
140 memories.push(row_to_memory(row)?);
141 }
142 Ok(memories)
143 })
144 .await
145 .map_err(|e| GraphBitError::memory(format!("Join error: {e}")))?
146 }
147
148 /// Update content and metadata of an existing memory.
149 pub async fn update_memory(

Callers 5

addMethod · 0.80
get_allMethod · 0.80
delete_allMethod · 0.80

Calls 3

build_scope_filterFunction · 0.85
row_to_memoryFunction · 0.85
cloneMethod · 0.80

Tested by 1