@mastra/core
Version:
Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.
55 lines (39 loc) • 1.36 kB
Markdown
The `.listMemory()` method returns all memory instances registered with the Mastra instance.
```typescript
const memoryInstances = mastra.listMemory()
for (const [key, memory] of Object.entries(memoryInstances)) {
console.log(`Memory "${key}": ${memory.id}`)
}
```
This method takes no parameters.
**memory** (`Record<string, MastraMemory>`): An object containing all registered memory instances, keyed by their registry keys.
```typescript
import { Mastra } from '@mastra/core'
import { Memory } from '@mastra/memory'
import { LibSQLStore } from '@mastra/libsql'
const conversationMemory = new Memory({
id: 'conversation-memory',
storage: new LibSQLStore({ id: 'conversation-store', url: ':memory:' }),
})
const analyticsMemory = new Memory({
id: 'analytics-memory',
storage: new LibSQLStore({ id: 'analytics-store', url: ':memory:' }),
})
const mastra = new Mastra({
memory: {
conversationMemory,
analyticsMemory,
},
})
// List all registered memory instances
const allMemory = mastra.listMemory()
console.log(Object.keys(allMemory)) // ["conversationMemory", "analyticsMemory"]
```
- [Mastra.getMemory()](https://mastra.ai/reference/core/getMemory)
- [Memory overview](https://mastra.ai/docs/memory/overview)