File tree 1 file changed +25
-0
lines changed
packages/adapter-mongodb/src
1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -1415,5 +1415,30 @@ export class MongoDBDatabaseAdapter
1415
1415
}
1416
1416
}
1417
1417
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
+
1418
1443
}
1419
1444
You can’t perform that action at this time.
0 commit comments