@mastra/mongodb 1.16.0-alpha.0 → 1.16.0-alpha.1
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/CHANGELOG.md +25 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +6 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @mastra/mongodb
|
|
2
2
|
|
|
3
|
+
## 1.16.0-alpha.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- When MongoDB storage initialization fails because an existing non-unique index conflicts with Mastra's required unique index, the error now includes step-by-step migration commands instead of a generic failure message. ([#20486](https://github.com/mastra-ai/mastra/pull/20486))
|
|
8
|
+
|
|
9
|
+
**Before:** `Failed to create default index on collection "mastra_threads". Set skipDefaultIndexes to manage indexes yourself.`
|
|
10
|
+
|
|
11
|
+
**After:**
|
|
12
|
+
|
|
13
|
+
```text
|
|
14
|
+
Index conflict on collection "mastra_threads": an existing non-unique index on { id: 1 }
|
|
15
|
+
conflicts with Mastra's required unique index.
|
|
16
|
+
|
|
17
|
+
To migrate:
|
|
18
|
+
1. Check for duplicates: db.mastra_threads.aggregate([{ $group: { _id: "$id", n: { $sum: 1 } } }, { $match: { n: { $gt: 1 } } }])
|
|
19
|
+
2. Drop the old index: db.mastra_threads.dropIndex("id_1")
|
|
20
|
+
3. Recreate as unique: db.mastra_threads.createIndex({ id: 1 }, { unique: true })
|
|
21
|
+
|
|
22
|
+
Alternatively, set skipDefaultIndexes: true to manage indexes yourself.
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
- Updated dependencies [[`594f7b2`](https://github.com/mastra-ai/mastra/commit/594f7b28f5263fb9982fd50d95c471fb971ea984), [`311f943`](https://github.com/mastra-ai/mastra/commit/311f943bee60e8fdf5c84499ea50e884276c936c), [`0c89896`](https://github.com/mastra-ai/mastra/commit/0c8989673fb7d106837098398131e570c6023b68), [`23b4238`](https://github.com/mastra-ai/mastra/commit/23b423844ad0bcf2a502a68dd62866d6160f9f6d), [`e320a76`](https://github.com/mastra-ai/mastra/commit/e320a763feaf65c6be3cebecf746defcbde161b3), [`03b4918`](https://github.com/mastra-ai/mastra/commit/03b4918c80d188ce375334c393e131c6e94bd7eb), [`14ef73a`](https://github.com/mastra-ai/mastra/commit/14ef73a4bbd73e7808414816eb0628ce1d80b5d7), [`1d677d5`](https://github.com/mastra-ai/mastra/commit/1d677d5f99d7db403f7828585e8c25f299f72628), [`93e28ec`](https://github.com/mastra-ai/mastra/commit/93e28ecce9031c02397e0ae8406593e5c7a95883), [`729dab4`](https://github.com/mastra-ai/mastra/commit/729dab408faccfaef0cbb048e5a4338f9172847e), [`484003d`](https://github.com/mastra-ai/mastra/commit/484003d33ff59330c86b19863e4a38732d7e4155), [`933d291`](https://github.com/mastra-ai/mastra/commit/933d291146b789c19442ad206f94da3e4be90c64)]:
|
|
26
|
+
- @mastra/core@1.56.0-alpha.3
|
|
27
|
+
|
|
3
28
|
## 1.16.0-alpha.0
|
|
4
29
|
|
|
5
30
|
### Minor Changes
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: mastra-mongodb
|
|
|
3
3
|
description: Documentation for @mastra/mongodb. Use when working with @mastra/mongodb APIs, configuration, or implementation.
|
|
4
4
|
metadata:
|
|
5
5
|
package: "@mastra/mongodb"
|
|
6
|
-
version: "1.16.0-alpha.
|
|
6
|
+
version: "1.16.0-alpha.1"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
package/dist/index.cjs
CHANGED
|
@@ -10,7 +10,7 @@ let _mastra_core_agent = require("@mastra/core/agent");
|
|
|
10
10
|
let _mastra_core_evals = require("@mastra/core/evals");
|
|
11
11
|
let _mastra_core_storage_domains_skills = require("@mastra/core/storage/domains/skills");
|
|
12
12
|
//#region package.json
|
|
13
|
-
var version = "1.16.0-alpha.
|
|
13
|
+
var version = "1.16.0-alpha.1";
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/vector/filter.ts
|
|
16
16
|
/**
|
|
@@ -5329,11 +5329,15 @@ var MemoryStorageMongoDB = class MemoryStorageMongoDB extends _mastra_core_stora
|
|
|
5329
5329
|
for (const indexDef of this.getDefaultIndexDefinitions()) try {
|
|
5330
5330
|
await (await this.getCollection(indexDef.collection)).createIndex(indexDef.keys, indexDef.options);
|
|
5331
5331
|
} catch (error) {
|
|
5332
|
+
const isUniqueConflict = error?.code === 85 && indexDef.options?.unique === true;
|
|
5333
|
+
const field = Object.keys(indexDef.keys)[0] ?? "id";
|
|
5334
|
+
const indexName = Object.entries(indexDef.keys).map(([k, v]) => `${k}_${v}`).join("_");
|
|
5335
|
+
const text = isUniqueConflict ? `Index conflict on collection "${indexDef.collection}": an existing non-unique index on { ${field}: 1 } conflicts with Mastra's required unique index.\n\nTo migrate:\n 1. Check for duplicates: db.${indexDef.collection}.aggregate([{ $group: { _id: "$${field}", n: { $sum: 1 } } }, { $match: { n: { $gt: 1 } } }])\n 2. Drop the old index: db.${indexDef.collection}.dropIndex("${indexName}")\n 3. Recreate as unique: db.${indexDef.collection}.createIndex({ ${field}: 1 }, { unique: true })\n\nAlternatively, set skipDefaultIndexes: true to manage indexes yourself.` : `Failed to create default index on collection "${indexDef.collection}". Set skipDefaultIndexes to manage indexes yourself.`;
|
|
5332
5336
|
throw new _mastra_core_error.MastraError({
|
|
5333
5337
|
id: (0, _mastra_core_storage.createStorageErrorId)("MONGODB", "CREATE_DEFAULT_INDEXES", "FAILED"),
|
|
5334
5338
|
domain: _mastra_core_error.ErrorDomain.STORAGE,
|
|
5335
5339
|
category: _mastra_core_error.ErrorCategory.THIRD_PARTY,
|
|
5336
|
-
text
|
|
5340
|
+
text,
|
|
5337
5341
|
details: { collection: indexDef.collection }
|
|
5338
5342
|
}, error);
|
|
5339
5343
|
}
|