@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/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
  }