@mastra/mongodb 0.10.4-alpha.0 → 0.11.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.
@@ -1,23 +1,23 @@
1
1
 
2
- > @mastra/mongodb@0.10.4-alpha.0 build /home/runner/work/mastra/mastra/stores/mongodb
2
+ > @mastra/mongodb@0.11.0-alpha.1 build /home/runner/work/mastra/mastra/stores/mongodb
3
3
  > tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting
4
4
 
5
5
  CLI Building entry: src/index.ts
6
6
  CLI Using tsconfig: tsconfig.json
7
7
  CLI tsup v8.5.0
8
8
  TSC Build start
9
- TSC ⚡️ Build success in 9012ms
9
+ TSC ⚡️ Build success in 8851ms
10
10
  DTS Build start
11
11
  CLI Target: es2022
12
12
  Analysis will use the bundled TypeScript version 5.8.3
13
13
  Writing package typings: /home/runner/work/mastra/mastra/stores/mongodb/dist/_tsup-dts-rollup.d.ts
14
14
  Analysis will use the bundled TypeScript version 5.8.3
15
15
  Writing package typings: /home/runner/work/mastra/mastra/stores/mongodb/dist/_tsup-dts-rollup.d.cts
16
- DTS ⚡️ Build success in 11981ms
16
+ DTS ⚡️ Build success in 12299ms
17
17
  CLI Cleaning output folder
18
18
  ESM Build start
19
19
  CJS Build start
20
- CJS dist/index.cjs 33.85 KB
21
- CJS ⚡️ Build success in 1175ms
22
- ESM dist/index.js 33.73 KB
23
- ESM ⚡️ Build success in 1175ms
20
+ ESM dist/index.js 33.93 KB
21
+ ESM ⚡️ Build success in 1218ms
22
+ CJS dist/index.cjs 34.07 KB
23
+ CJS ⚡️ Build success in 1218ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,53 @@
1
1
  # @mastra/mongodb
2
2
 
3
+ ## 0.11.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 704d1ca: Thread Timestamp Auto-Update Enhancement
8
+ Added automatic thread updatedAt timestamp updates when messages are saved across all storage providers
9
+ Enhanced user experience: Threads now accurately reflect their latest activity with automatic timestamp updates when new messages are added
10
+ Universal implementation: Consistent behavior across all 7 storage backends (ClickHouse, Cloudflare D1, DynamoDB, MongoDB, PostgreSQL, Upstash, LibSQL)
11
+ Performance optimized: Updates execute in parallel with message saving operations for minimal performance impact
12
+ Backwards compatible: No breaking changes - existing code continues to work unchanged
13
+ Improved conversation ordering: Chat interfaces can now properly sort threads by actual last activity
14
+ This enhancement resolves the issue where active conversations appeared stale due to outdated thread timestamps, providing better conversation management and user experience in chat applications.
15
+
16
+ ### Patch Changes
17
+
18
+ - 63f6b7d: dependencies updates:
19
+ - Updated dependency [`cloudflare@^4.3.0` ↗︎](https://www.npmjs.com/package/cloudflare/v/4.3.0) (from `^4.1.0`, in `dependencies`)
20
+ - Updated dependency [`mongodb@^6.17.0` ↗︎](https://www.npmjs.com/package/mongodb/v/6.17.0) (from `^6.15.0`, in `dependencies`)
21
+ - Updated dependencies [63f6b7d]
22
+ - Updated dependencies [12a95fc]
23
+ - Updated dependencies [4b0f8a6]
24
+ - Updated dependencies [51264a5]
25
+ - Updated dependencies [8e6f677]
26
+ - Updated dependencies [d70c420]
27
+ - Updated dependencies [ee9af57]
28
+ - Updated dependencies [36f1c36]
29
+ - Updated dependencies [2a16996]
30
+ - Updated dependencies [10d352e]
31
+ - Updated dependencies [9589624]
32
+ - Updated dependencies [53d3c37]
33
+ - Updated dependencies [751c894]
34
+ - Updated dependencies [577ce3a]
35
+ - Updated dependencies [9260b3a]
36
+ - @mastra/core@0.10.6
37
+
38
+ ## 0.11.0-alpha.1
39
+
40
+ ### Minor Changes
41
+
42
+ - 704d1ca: Thread Timestamp Auto-Update Enhancement
43
+ Added automatic thread updatedAt timestamp updates when messages are saved across all storage providers
44
+ Enhanced user experience: Threads now accurately reflect their latest activity with automatic timestamp updates when new messages are added
45
+ Universal implementation: Consistent behavior across all 7 storage backends (ClickHouse, Cloudflare D1, DynamoDB, MongoDB, PostgreSQL, Upstash, LibSQL)
46
+ Performance optimized: Updates execute in parallel with message saving operations for minimal performance impact
47
+ Backwards compatible: No breaking changes - existing code continues to work unchanged
48
+ Improved conversation ordering: Chat interfaces can now properly sort threads by actual last activity
49
+ This enhancement resolves the issue where active conversations appeared stale due to outdated thread timestamps, providing better conversation management and user experience in chat applications.
50
+
3
51
  ## 0.10.4-alpha.0
4
52
 
5
53
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -669,7 +669,11 @@ var MongoDBStore = class extends storage.MastraStorage {
669
669
  };
670
670
  });
671
671
  const collection = await this.getCollection(storage.TABLE_MESSAGES);
672
- await collection.insertMany(messagesToInsert);
672
+ const threadsCollection = await this.getCollection(storage.TABLE_THREADS);
673
+ await Promise.all([
674
+ collection.insertMany(messagesToInsert),
675
+ threadsCollection.updateOne({ id: threadId }, { $set: { updatedAt: /* @__PURE__ */ new Date() } })
676
+ ]);
673
677
  const list = new agent.MessageList().add(messages, "memory");
674
678
  if (format === `v2`) return list.get.all.v2();
675
679
  return list.get.all.v1();
package/dist/index.js CHANGED
@@ -667,7 +667,11 @@ var MongoDBStore = class extends MastraStorage {
667
667
  };
668
668
  });
669
669
  const collection = await this.getCollection(TABLE_MESSAGES);
670
- await collection.insertMany(messagesToInsert);
670
+ const threadsCollection = await this.getCollection(TABLE_THREADS);
671
+ await Promise.all([
672
+ collection.insertMany(messagesToInsert),
673
+ threadsCollection.updateOne({ id: threadId }, { $set: { updatedAt: /* @__PURE__ */ new Date() } })
674
+ ]);
671
675
  const list = new MessageList().add(messages, "memory");
672
676
  if (format === `v2`) return list.get.all.v2();
673
677
  return list.get.all.v1();
@@ -1,6 +1,6 @@
1
1
  services:
2
2
  mongodb-storage:
3
- image: mongo:6.0.16
3
+ image: mongo:6.0.24
4
4
  container_name: 'mongodb-storage-test-db'
5
5
  ports:
6
6
  - '27017:27017'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/mongodb",
3
- "version": "0.10.4-alpha.0",
3
+ "version": "0.11.0",
4
4
  "description": "MongoDB provider for Mastra - includes vector store capabilities",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -31,9 +31,9 @@
31
31
  "tsup": "^8.5.0",
32
32
  "typescript": "^5.8.3",
33
33
  "vitest": "^3.2.3",
34
- "@internal/lint": "0.0.12",
35
- "@internal/storage-test-utils": "0.0.8",
36
- "@mastra/core": "0.10.6-alpha.0"
34
+ "@internal/lint": "0.0.13",
35
+ "@internal/storage-test-utils": "0.0.9",
36
+ "@mastra/core": "0.10.6"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@mastra/core": ">=0.10.4-0 <0.11.0"
@@ -272,6 +272,27 @@ describe('MongoDBStore', () => {
272
272
  expect(retrievedThread?.title).toBe('Updated Title');
273
273
  expect(retrievedThread?.metadata).toEqual({ key: 'newValue' });
274
274
  });
275
+
276
+ it('should update thread updatedAt when a message is saved to it', async () => {
277
+ const test = new Test(store).build();
278
+ await test.clearTables();
279
+
280
+ const thread = test.generateSampleThread();
281
+ await store.saveThread({ thread });
282
+
283
+ const initialThread = await store.getThreadById({ threadId: thread.id });
284
+ expect(initialThread).toBeDefined();
285
+ const originalUpdatedAt = initialThread!.updatedAt;
286
+
287
+ await new Promise(resolve => setTimeout(resolve, 10));
288
+
289
+ const message = test.generateSampleMessageV1({ threadId: thread.id });
290
+ await store.saveMessages({ messages: [message] });
291
+
292
+ const updatedThread = await store.getThreadById({ threadId: thread.id });
293
+ expect(updatedThread).toBeDefined();
294
+ expect(updatedThread!.updatedAt.getTime()).toBeGreaterThan(originalUpdatedAt.getTime());
295
+ });
275
296
  });
276
297
 
277
298
  describe('Message Operations', () => {
@@ -344,6 +344,7 @@ export class MongoDBStore extends MastraStorage {
344
344
  this.logger.error('Thread ID is required to save messages');
345
345
  throw new Error('Thread ID is required');
346
346
  }
347
+
347
348
  try {
348
349
  // Prepare batch statements for all messages
349
350
  const messagesToInsert = messages.map(message => {
@@ -359,9 +360,15 @@ export class MongoDBStore extends MastraStorage {
359
360
  };
360
361
  });
361
362
 
362
- // Execute all inserts in a single batch
363
+ // Execute message inserts and thread update in parallel for better performance
363
364
  const collection = await this.getCollection(TABLE_MESSAGES);
364
- await collection.insertMany(messagesToInsert);
365
+ const threadsCollection = await this.getCollection(TABLE_THREADS);
366
+
367
+ await Promise.all([
368
+ collection.insertMany(messagesToInsert),
369
+ threadsCollection.updateOne({ id: threadId }, { $set: { updatedAt: new Date() } }),
370
+ ]);
371
+
365
372
  const list = new MessageList().add(messages, 'memory');
366
373
  if (format === `v2`) return list.get.all.v2();
367
374
  return list.get.all.v1();