Skip to content

Commit 65d9428

Browse files
committed
Update index.ts
1 parent dfbf3ec commit 65d9428

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

packages/adapter-mongodb/src/index.ts

+25
Original file line numberDiff line numberDiff line change
@@ -1415,5 +1415,30 @@ export class MongoDBDatabaseAdapter
14151415
}
14161416
}
14171417

1418+
async getMemoriesByIds(memoryIds: UUID[], tableName?: string): Promise<Memory[]> {
1419+
await this.ensureConnection();
1420+
const collection = tableName || 'memories';
1421+
1422+
try {
1423+
const memories = await this.database.collection(collection)
1424+
.find({ id: { $in: memoryIds } })
1425+
.toArray();
1426+
1427+
return memories.map(memory => ({
1428+
id: memory.id,
1429+
roomId: memory.roomId,
1430+
agentId: memory.agentId,
1431+
type: memory.type,
1432+
content: memory.content,
1433+
embedding: memory.embedding,
1434+
createdAt: memory.createdAt instanceof Date ? memory.createdAt.getTime() : memory.createdAt,
1435+
metadata: memory.metadata || {}
1436+
}));
1437+
} catch (error) {
1438+
elizaLogger.error('Failed to get memories by IDs:', error);
1439+
return [];
1440+
}
1441+
}
1442+
14181443
}
14191444

0 commit comments

Comments
 (0)