Memory Examples
Practical examples for creating, searching, and managing memories
This page provides practical examples for common memory management patterns and use cases.
Create a task with priority and deadline metadata.
const result = await mirra.memory.create({
type: "task",
content: "Review Q1 financial reports and prepare summary",
metadata: {
priority: "high",
deadline: "2024-01-26T17:00:00Z",
status: "open",
effort_level: "medium"
}
});
console.log(`Task created with ID: ${result.data.id}`);
Response:
{
"id": "op_abc123",
"status": "success",
"timestamp": "2024-01-20T10:30:00Z",
"data": {
"id": "task_xyz789",
"type": "task",
"content": "Review Q1 financial reports and prepare summary",
"metadata": {
"priority": "high",
"deadline": "2024-01-26T17:00:00Z",
"status": "open"
},
"createdAt": 1705748400000
}
}
Store meeting notes with categorization.
const result = await mirra.memory.create({
type: "note",
content: "Team standup - discussed sprint planning and resource allocation for Q1",
metadata: {
category: "meeting",
importance: "medium",
tags: ["team", "planning", "q1-2024"]
}
});
Capture a business idea with feasibility assessment.
const result = await mirra.memory.create({
type: "idea",
content: "Build a browser extension for automated email categorization using AI",
metadata: {
idea_type: "business",
feasibility: "medium",
development_effort: "month_project",
tags: ["ai", "productivity", "chrome-extension"]
}
});
Add an item to your shopping list.
const result = await mirra.memory.create({
type: "shopping_item",
content: "Organic blueberries",
metadata: {
priority: "medium",
store_preference: "Whole Foods",
category: "produce",
status: "open"
}
});
Find memories related to a concept using semantic similarity.
const results = await mirra.memory.search({
query: "upcoming work deadlines",
limit: 10
});
// Results are ranked by semantic similarity
for (const item of results.data.items) {
console.log(`${item.type}: ${item.content} (score: ${item.score})`);
}
Response:
{
"id": "op_search_123",
"status": "success",
"data": {
"items": [
{
"id": "task_abc123",
"type": "task",
"content": "Review Q1 financial reports and prepare summary",
"metadata": { "deadline": "2024-01-26T17:00:00Z" },
"score": 0.92
},
{
"id": "task_def456",
"type": "task",
"content": "Submit project proposal by end of month",
"metadata": { "deadline": "2024-01-31T23:59:59Z" },
"score": 0.87
}
],
"pagination": {
"totalCount": 2,
"limit": 10,
"offset": 0,
"hasMore": false
}
}
}
Find all open high-priority tasks.
const results = await mirra.memory.query({
type: "task",
filters: {
status: "open",
priority: "high"
},
limit: 20,
offset: 0
});
console.log(`Found ${results.data.items.length} high-priority tasks`);
Get all items in a specific category.
const results = await mirra.memory.query({
type: "shopping_item",
filters: {
status: "open",
category: "produce"
},
limit: 50
});
Find all notes tagged with a specific keyword.
const results = await mirra.memory.query({
type: "note",
filters: {
tags: { contains: "planning" }
},
limit: 20
});
Mark a task as completed.
const result = await mirra.memory.update({
id: "task_abc123",
metadata: {
status: "completed",
completedAt: Date.now()
}
});
Change task priority and add notes.
const result = await mirra.memory.update({
id: "task_xyz789",
metadata: {
priority: "high",
notes: "Bumped priority due to client request"
}
});
Mark a shopping item as purchased.
const result = await mirra.memory.update({
id: "shopping_item_123",
metadata: {
status: "purchased",
purchasedAt: Date.now(),
actualStore: "Whole Foods"
}
});
Modify the content of an existing note.
const result = await mirra.memory.update({
id: "note_abc123",
content: "Updated meeting notes - added action items and follow-up dates",
metadata: {
updatedAt: Date.now(),
tags: ["team", "planning", "q1-2024", "action-items"]
}
});
Remove a task that's no longer needed.
const result = await mirra.memory.delete({
id: "task_abc123"
});
console.log(`Task deleted: ${result.data.success}`);
Delete several shopping items at once.
const itemIds = ["shopping_item_1", "shopping_item_2", "shopping_item_3"];
for (const id of itemIds) {
await mirra.memory.delete({ id });
}
Retrieve a specific task's full details.
const task = await mirra.memory.findOne({
filters: { id: "task_abc123" }
});
if (task.data.entity) {
console.log(`Task: ${task.data.entity.content}`);
console.log(`Status: ${task.data.entity.metadata.status}`);
}
Search for a note containing specific text.
const note = await mirra.memory.findOne({
filters: {
type: "note",
content: { contains: "sprint planning" }
}
});
Upload a document and perform semantic search across its chunks.
// Upload a document
const uploadResult = await mirra.memory.uploadDocument({
file: base64EncodedContent,
filename: "product_requirements.pdf",
mimeType: "application/pdf",
title: "Product Requirements Document Q1 2024"
});
console.log(`Document uploaded: ${uploadResult.data.documentId}`);
// Search across document chunks
const searchResults = await mirra.memory.searchDocuments({
query: "authentication requirements",
limit: 5
});
for (const chunk of searchResults.data.items) {
console.log(`Page ${chunk.pageNumber}: ${chunk.text.substring(0, 100)}...`);
}
Monitor document processing progress.
const status = await mirra.memory.getDocumentStatus({
documentId: "doc_abc123"
});
console.log(`Processing status: ${status.data.processingStatus}`);
console.log(`Chunks created: ${status.data.chunkCount}`);
Get all chunks for detailed analysis.
const chunks = await mirra.memory.getDocumentChunks({
documentId: "doc_abc123"
});
console.log(`Total chunks: ${chunks.data.items.length}`);
for (const chunk of chunks.data.items) {
console.log(`Chunk ${chunk.chunkIndex}: ${chunk.text}`);
}
Complete workflow for task creation, tracking, and completion.
// Create a task
const createResult = await mirra.memory.create({
type: "task",
content: "Prepare investor presentation",
metadata: {
priority: "high",
deadline: "2024-02-01T17:00:00Z",
status: "open"
}
});
const taskId = createResult.data.id;
// Update progress
await mirra.memory.update({
id: taskId,
metadata: {
status: "in_progress",
progress_notes: "Started outline and key talking points"
}
});
// Mark as completed
await mirra.memory.update({
id: taskId,
metadata: {
status: "completed",
completedAt: Date.now(),
completion_notes: "Presentation delivered successfully"
}
});
Manage a shopping list from creation to purchase.
// Add items to list
const items = [
{ content: "Milk", category: "dairy" },
{ content: "Bread", category: "bakery" },
{ content: "Apples", category: "produce" }
];
for (const item of items) {
await mirra.memory.create({
type: "shopping_item",
content: item.content,
metadata: {
category: item.category,
status: "open",
priority: "medium"
}
});
}
// Get active shopping list
const activeItems = await mirra.memory.query({
type: "shopping_item",
filters: { status: "open" },
limit: 100
});
console.log(`Shopping list: ${activeItems.data.items.length} items`);
// Mark items as purchased
for (const item of activeItems.data.items) {
if (item.content === "Milk") {
await mirra.memory.update({
id: item.id,
metadata: {
status: "purchased",
purchasedAt: Date.now()
}
});
}
}
Build a searchable knowledge base from notes and documents.
// Add reference notes
await mirra.memory.create({
type: "note",
content: "API authentication uses OAuth 2.0 with refresh token rotation",
metadata: {
category: "reference",
tags: ["api", "authentication", "oauth"],
importance: "high"
}
});
// Search knowledge base
const results = await mirra.memory.search({
query: "how does authentication work",
limit: 5
});
// Display relevant results
for (const item of results.data.items) {
console.log(`\n${item.type}: ${item.content}`);
console.log(`Relevance: ${(item.score * 100).toFixed(1)}%`);
}
- Operations - Complete API reference for all memory operations
- Overview - Memory system concepts and architecture
- Technical Notes - Graph structure, embeddings, and performance tips
- Documents - Document management examples
- Flows - Automate memory operations with workflows
- Scripts - Build custom memory management logic