@mastra/mongodb 0.13.2 → 0.13.3-alpha.0
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 +9 -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 +4 -4
- package/src/storage/domains/memory/index.ts +45 -0
- package/src/storage/index.ts +12 -0
package/.turbo/turbo-build.log
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @mastra/mongodb
|
|
2
2
|
|
|
3
|
+
## 0.13.3-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#6700](https://github.com/mastra-ai/mastra/pull/6700) [`a5a23d9`](https://github.com/mastra-ai/mastra/commit/a5a23d981920d458dc6078919992a5338931ef02) Thanks [@gpanakkal](https://github.com/gpanakkal)! - Add `getMessagesById` method to `MastraStorage` adapters
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`6e7e120`](https://github.com/mastra-ai/mastra/commit/6e7e1207d6e8d8b838f9024f90bd10df1181ba27), [`a5a23d9`](https://github.com/mastra-ai/mastra/commit/a5a23d981920d458dc6078919992a5338931ef02)]:
|
|
10
|
+
- @mastra/core@0.14.1-alpha.0
|
|
11
|
+
|
|
3
12
|
## 0.13.2
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -925,6 +925,29 @@ var MemoryStorageMongoDB = class extends storage.MemoryStorage {
|
|
|
925
925
|
);
|
|
926
926
|
}
|
|
927
927
|
}
|
|
928
|
+
async getMessagesById({
|
|
929
|
+
messageIds,
|
|
930
|
+
format
|
|
931
|
+
}) {
|
|
932
|
+
if (messageIds.length === 0) return [];
|
|
933
|
+
try {
|
|
934
|
+
const collection = await this.operations.getCollection(storage.TABLE_MESSAGES);
|
|
935
|
+
const rawMessages = await collection.find({ id: { $in: messageIds } }).sort({ createdAt: -1 }).toArray();
|
|
936
|
+
const list = new agent.MessageList().add(rawMessages.map(this.parseRow), "memory");
|
|
937
|
+
if (format === `v1`) return list.get.all.v1();
|
|
938
|
+
return list.get.all.v2();
|
|
939
|
+
} catch (error$1) {
|
|
940
|
+
throw new error.MastraError(
|
|
941
|
+
{
|
|
942
|
+
id: "MONGODB_STORE_GET_MESSAGES_BY_ID_FAILED",
|
|
943
|
+
domain: error.ErrorDomain.STORAGE,
|
|
944
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
945
|
+
details: { messageIds: JSON.stringify(messageIds) }
|
|
946
|
+
},
|
|
947
|
+
error$1
|
|
948
|
+
);
|
|
949
|
+
}
|
|
950
|
+
}
|
|
928
951
|
async getMessagesPaginated(args) {
|
|
929
952
|
const { threadId, format, selectBy } = args;
|
|
930
953
|
const { page = 0, perPage: perPageInput, dateRange } = selectBy?.pagination || {};
|
|
@@ -2235,6 +2258,12 @@ var MongoDBStore = class extends storage.MastraStorage {
|
|
|
2235
2258
|
}) {
|
|
2236
2259
|
return this.stores.memory.getMessages({ threadId, selectBy, format });
|
|
2237
2260
|
}
|
|
2261
|
+
async getMessagesById({
|
|
2262
|
+
messageIds,
|
|
2263
|
+
format
|
|
2264
|
+
}) {
|
|
2265
|
+
return this.stores.memory.getMessagesById({ messageIds, format });
|
|
2266
|
+
}
|
|
2238
2267
|
async saveMessages(args) {
|
|
2239
2268
|
return this.stores.memory.saveMessages(args);
|
|
2240
2269
|
}
|