@mastra/mongodb 1.18.5-alpha.1 → 1.18.5

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/README.md CHANGED
@@ -8,11 +8,6 @@ MongoDB Atlas Search implementation for Mastra, providing vector similarity sear
8
8
  npm install @mastra/mongodb
9
9
  ```
10
10
 
11
- ## Prerequisites
12
-
13
- - MongoDB Atlas Local (via Docker) or MongoDB Atlas Cloud instance with Atlas Search enabled
14
- - MongoDB 7.0+ recommended
15
-
16
11
  ## Usage
17
12
 
18
13
  ### Vector Store
@@ -32,21 +27,24 @@ await vectorDB.connect();
32
27
  // Create a new vector index (collection)
33
28
  await vectorDB.createIndex({
34
29
  indexName: 'my_vectors',
35
- dimension: 1536,
30
+ dimension: 3,
36
31
  metric: 'cosine', // or 'euclidean', 'dotproduct'
37
32
  });
38
33
 
39
34
  // Upsert vectors
40
35
  const ids = await vectorDB.upsert({
41
36
  indexName: 'my_vectors',
42
- vectors: [[0.1, 0.2, ...], [0.3, 0.4, ...]],
37
+ vectors: [
38
+ [0.1, 0.2, 0.3],
39
+ [0.3, 0.4, 0.5],
40
+ ],
43
41
  metadata: [{ text: 'doc1' }, { text: 'doc2' }],
44
42
  });
45
43
 
46
44
  // Query vectors
47
45
  const results = await vectorDB.query({
48
46
  indexName: 'my_vectors',
49
- queryVector: [0.1, 0.2, ...],
47
+ queryVector: [0.1, 0.2, 0.3],
50
48
  topK: 10,
51
49
  filter: { text: 'doc1' },
52
50
  includeVector: false,
@@ -56,158 +54,15 @@ const results = await vectorDB.query({
56
54
  await vectorDB.disconnect();
57
55
  ```
58
56
 
59
- ### Storage
60
-
61
- ```typescript
62
- import { MongoDBStore } from '@mastra/mongodb';
63
-
64
- const store = new MongoDBStore({
65
- id: 'mongodb-store',
66
- uri: 'mongodb://mongodb:mongodb@localhost:27018/?authSource=admin&directConnection=true',
67
- dbName: 'mastra',
68
- });
69
-
70
- // Create a thread
71
- await store.saveThread({
72
- thread: {
73
- id: 'thread-123',
74
- resourceId: 'resource-456',
75
- title: 'My Thread',
76
- metadata: { key: 'value' },
77
- createdAt: new Date(),
78
- },
79
- });
80
-
81
- // Add messages to thread
82
- await store.saveMessages({
83
- messages: [
84
- {
85
- id: 'msg-789',
86
- threadId: 'thread-123',
87
- role: 'user',
88
- content: { content: 'Hello' },
89
- resourceId: 'resource-456',
90
- createdAt: new Date(),
91
- },
92
- ],
93
- });
94
-
95
- // Query threads and messages
96
- const savedThread = await store.getThreadById({ threadId: 'thread-123' });
97
- const { messages } = await store.listMessages({ threadId: 'thread-123' });
98
- ```
99
-
100
- ## Configuration
101
-
102
- The MongoDB vector store is initialized with:
103
-
104
- - `id`: Unique identifier for this store instance
105
- - `uri`: MongoDB connection string (with credentials and options)
106
- - `dbName`: Name of the database to use
107
- - `embeddingFieldPath` (optional): Path to the field that stores vector embeddings. Supports nested paths using dot notation (e.g., `'text.contentEmbedding'`). Defaults to `'embedding'`.
108
-
109
- Example:
110
-
111
- ```typescript
112
- const vectorDB = new MongoDBVector({
113
- id: 'mongodb-vector',
114
- uri: 'mongodb://mongodb:mongodb@localhost:27018/?authSource=admin&directConnection=true',
115
- dbName: 'vector_db',
116
- });
117
- ```
118
-
119
- ### Custom Embedding Field Path
120
-
121
- If you need to store embeddings in a nested field structure, use the `embeddingFieldPath` option:
122
-
123
- ```typescript
124
- const vectorDB = new MongoDBVector({
125
- id: 'mongodb-vector',
126
- uri: 'mongodb://mongodb:mongodb@localhost:27018/?authSource=admin&directConnection=true',
127
- dbName: 'vector_db',
128
- embeddingFieldPath: 'text.contentEmbedding', // Store embeddings at text.contentEmbedding
129
- });
130
- ```
131
-
132
- ## Features
133
-
134
- ### Vector Store Features
135
-
136
- - Vector similarity search with cosine, euclidean, and dotproduct metrics (Atlas Search)
137
- - Metadata filtering with MongoDB-style query syntax
138
- - Automatic UUID generation for vectors
139
- - Collection (index) management: create, list, describe, delete
140
- - Atlas Search readiness checks for reliable testing
141
-
142
- ### Storage Features
143
-
144
- - Thread and message storage with JSON support
145
- - Efficient batch operations
146
- - Rich metadata support
147
- - Timestamp tracking
148
-
149
- ## Supported Filter Operators
150
-
151
- - Comparison: `$eq`, `$ne`, `$gt`, `$gte`, `$lt`, `$lte`
152
- - Logical: `$and`, `$or`
153
- - Array: `$in`, `$nin`
154
- - Text: `$regex`, `$like`
155
-
156
- Example filter:
157
-
158
- ```typescript
159
- {
160
- $and: [{ age: { $gt: 25 } }, { tags: { $in: ['tag1', 'tag2'] } }];
161
- }
162
- ```
163
-
164
- ## Distance Metrics
165
-
166
- The following distance metrics are supported:
167
-
168
- - `cosine` → Cosine similarity (default)
169
- - `euclidean` → Euclidean distance
170
- - `dotproduct` → Dot product
171
-
172
- ## Vector Store Methods
173
-
174
- - `createIndex({indexName, dimension, metric})`: Create a new collection with vector search support
175
- - `upsert({indexName, vectors, metadata?, ids?})`: Add or update vectors
176
- - `query({indexName, queryVector, topK?, filter?, includeVector?, documentFilter?})`: Search for similar vectors (optionally filter by document content)
177
-
178
- > **Note:** `documentFilter` allows filtering results based on the content of the `document` field. Example: `{ $contains: 'specific text' }` will return only vectors whose associated document contains the specified text.
179
-
180
- - `updateVector({ indexName, id?, filter?, update })`: Update a single vector by ID or metadata filter
181
- - `deleteVector({ indexName, id })`: Delete a single vector by ID
182
- - `deleteVectors({ indexName, ids?, filter? })`: Delete multiple vectors by IDs or metadata filter
183
- - `listIndexes()`: List all vector-enabled collections
184
- - `describeIndex(indexName)`: Get collection statistics (dimension, count, metric)
185
- - `deleteIndex(indexName)`: Delete a collection
186
- - `disconnect()`: Close the MongoDB connection
187
-
188
- ## Storage Methods
189
-
190
- - `saveThread({ thread })`: Create or update a thread
191
- - `getThreadById({ threadId })`: Get a thread by ID
192
- - `deleteThread({ threadId })`: Delete a thread and its messages
193
- - `saveMessages({ messages })`: Save multiple messages in a transaction
194
- - `listMessages({ threadId, perPage?, page? })`: Get messages for a thread with pagination
195
- - `deleteMessages(messageIds)`: Delete specific messages
196
-
197
- ## Query Response Format
198
-
199
- Each query result includes:
57
+ ## Documentation
200
58
 
201
- - `id`: Vector ID
202
- - `score`: Similarity score (higher is more similar)
203
- - `metadata`: Associated metadata
204
- - `vector`: Original vector (if `includeVector` is true)
59
+ - [MongoDB integration guide](https://mastra.ai/integrations/databases/mongodb)
60
+ - [MongoDB vector reference](https://mastra.ai/reference/vectors/mongodb)
205
61
 
206
- ## Testing
62
+ ## Changelog
207
63
 
208
- Integration tests use MongoDB Atlas Local via Docker. See `docker-compose.yml` for setup. The test suite includes readiness checks for Atlas Search before running vector operations.
64
+ See the [package changelog](https://github.com/mastra-ai/mastra/blob/main/stores/mongodb/CHANGELOG.md) for version history and release notes.
209
65
 
210
- ## Related Links
66
+ ## Support
211
67
 
212
- - [MongoDB Atlas Search Documentation](https://www.mongodb.com/docs/atlas/atlas-search/)
213
- - [MongoDB Node.js Driver](https://mongodb.github.io/node-mongodb-native/)
68
+ We have an [open community Discord](https://discord.gg/mastra-ai). Come and say hello and let us know if you have any questions or need any help getting things running.
@@ -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.18.5-alpha.1"
6
+ version: "1.18.5"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.18.5-alpha.1",
2
+ "version": "1.18.5",
3
3
  "package": "@mastra/mongodb",
4
4
  "exports": {},
5
5
  "modules": {}
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.18.5-alpha.1";
13
+ var version = "1.18.5";
14
14
  //#endregion
15
15
  //#region src/vector/filter.ts
16
16
  /**
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import { MessageList } from "@mastra/core/agent";
9
9
  import { saveScorePayloadSchema } from "@mastra/core/evals";
10
10
  import { skillSnapshotFieldValuesEqual } from "@mastra/core/storage/domains/skills";
11
11
  //#region package.json
12
- var version = "1.18.5-alpha.1";
12
+ var version = "1.18.5";
13
13
  //#endregion
14
14
  //#region src/vector/filter.ts
15
15
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/mongodb",
3
- "version": "1.18.5-alpha.1",
3
+ "version": "1.18.5",
4
4
  "description": "MongoDB provider for Mastra - includes vector store capabilities",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -32,10 +32,10 @@
32
32
  "tsx": "^4.23.1",
33
33
  "typescript": "^7.0.2",
34
34
  "vitest": "4.1.10",
35
- "@internal/lint": "0.0.129",
36
- "@internal/types-builder": "0.0.104",
37
- "@mastra/core": "1.64.0-alpha.5",
38
- "@internal/storage-test-utils": "0.0.125"
35
+ "@internal/lint": "0.0.130",
36
+ "@internal/storage-test-utils": "0.0.126",
37
+ "@internal/types-builder": "0.0.105",
38
+ "@mastra/core": "1.64.0"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "@mastra/core": ">=1.63.1-0 <2.0.0-0"