MCPcopy Index your code
hub / github.com/InfinitiBit/graphbit / get_memory

Method get_memory

core/src/memory/store.rs:101–118  ·  view source on GitHub ↗

Get a single memory by ID.

(&self, memory_id: &MemoryId)

Source from the content-addressed store, hash-verified

99
100 /// Get a single memory by ID.
101 pub async fn get_memory(&self, memory_id: &MemoryId) -> GraphBitResult<Option<Memory>> {
102 let id = memory_id.to_string();
103 let conn_arc = Arc::clone(&self.conn);
104
105 tokio::task::spawn_blocking(move || -> GraphBitResult<Option<Memory>> {
106 let conn = conn_arc.blocking_lock();
107 let mut stmt =
108 conn.prepare("SELECT id, content, user_id, agent_id, run_id, hash, metadata, created_at, updated_at FROM memories WHERE id = ?1")?;
109 let mut rows = stmt.query(rusqlite::params![id])?;
110 if let Some(row) = rows.next()? {
111 Ok(Some(row_to_memory(row)?))
112 } else {
113 Ok(None)
114 }
115 })
116 .await
117 .map_err(|e| GraphBitError::memory(format!("Join error: {e}")))?
118 }
119
120 /// Get all memories matching the given scope.
121 pub async fn get_all_memories(&self, scope: &MemoryScope) -> GraphBitResult<Vec<Memory>> {

Callers 7

addMethod · 0.80
searchMethod · 0.80
getMethod · 0.80
updateMethod · 0.80
deleteMethod · 0.80
test_metadata_store_crudFunction · 0.80

Calls 2

row_to_memoryFunction · 0.85
to_stringMethod · 0.80

Tested by 1

test_metadata_store_crudFunction · 0.64