@mastra/mongodb 0.13.2 → 0.13.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +18 -0
- package/dist/index.cjs +29 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +8 -0
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +8 -0
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/storage/domains/memory/index.ts +45 -0
- package/src/storage/index.ts +12 -0
package/dist/index.js
CHANGED
|
@@ -923,6 +923,29 @@ var MemoryStorageMongoDB = class extends MemoryStorage {
|
|
|
923
923
|
);
|
|
924
924
|
}
|
|
925
925
|
}
|
|
926
|
+
async getMessagesById({
|
|
927
|
+
messageIds,
|
|
928
|
+
format
|
|
929
|
+
}) {
|
|
930
|
+
if (messageIds.length === 0) return [];
|
|
931
|
+
try {
|
|
932
|
+
const collection = await this.operations.getCollection(TABLE_MESSAGES);
|
|
933
|
+
const rawMessages = await collection.find({ id: { $in: messageIds } }).sort({ createdAt: -1 }).toArray();
|
|
934
|
+
const list = new MessageList().add(rawMessages.map(this.parseRow), "memory");
|
|
935
|
+
if (format === `v1`) return list.get.all.v1();
|
|
936
|
+
return list.get.all.v2();
|
|
937
|
+
} catch (error) {
|
|
938
|
+
throw new MastraError(
|
|
939
|
+
{
|
|
940
|
+
id: "MONGODB_STORE_GET_MESSAGES_BY_ID_FAILED",
|
|
941
|
+
domain: ErrorDomain.STORAGE,
|
|
942
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
943
|
+
details: { messageIds: JSON.stringify(messageIds) }
|
|
944
|
+
},
|
|
945
|
+
error
|
|
946
|
+
);
|
|
947
|
+
}
|
|
948
|
+
}
|
|
926
949
|
async getMessagesPaginated(args) {
|
|
927
950
|
const { threadId, format, selectBy } = args;
|
|
928
951
|
const { page = 0, perPage: perPageInput, dateRange } = selectBy?.pagination || {};
|
|
@@ -2233,6 +2256,12 @@ var MongoDBStore = class extends MastraStorage {
|
|
|
2233
2256
|
}) {
|
|
2234
2257
|
return this.stores.memory.getMessages({ threadId, selectBy, format });
|
|
2235
2258
|
}
|
|
2259
|
+
async getMessagesById({
|
|
2260
|
+
messageIds,
|
|
2261
|
+
format
|
|
2262
|
+
}) {
|
|
2263
|
+
return this.stores.memory.getMessagesById({ messageIds, format });
|
|
2264
|
+
}
|
|
2236
2265
|
async saveMessages(args) {
|
|
2237
2266
|
return this.stores.memory.saveMessages(args);
|
|
2238
2267
|
}
|