@mastra/mongodb 1.24.1 → 1.25.0-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/README.md +1 -1
- package/dist/docs/SKILL.md +2 -2
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-memory-semantic-recall.md +20 -20
- package/dist/docs/references/integrations-databases-mongodb.md +1 -1
- package/dist/docs/references/{reference-vectors-mongodb.md → integrations-vectors-mongodb.md} +2 -0
- package/dist/docs/references/reference-rag-vector-databases.md +3 -3
- package/dist/index.cjs +15 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -5
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/background-tasks/index.d.ts +1 -0
- package/dist/storage/domains/background-tasks/index.d.ts.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -57,7 +57,7 @@ await vectorDB.disconnect();
|
|
|
57
57
|
## Documentation
|
|
58
58
|
|
|
59
59
|
- [MongoDB integration guide](https://mastra.ai/integrations/databases/mongodb)
|
|
60
|
-
- [MongoDB vector reference](https://mastra.ai/
|
|
60
|
+
- [MongoDB vector reference](https://mastra.ai/integrations/vectors/mongodb)
|
|
61
61
|
|
|
62
62
|
## Changelog
|
|
63
63
|
|
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.
|
|
6
|
+
version: "1.25.0-alpha.0"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -23,6 +23,7 @@ Read the individual reference documents for detailed explanations and code examp
|
|
|
23
23
|
### Integrations
|
|
24
24
|
|
|
25
25
|
- [MongoDB](references/integrations-databases-mongodb.md) - Store Mastra application data and vectors in MongoDB, configure connections and collections, initialize schemas, and add persistent agent memory.
|
|
26
|
+
- [MongoDB](references/integrations-vectors-mongodb.md) - Run MongoDB Vector Search from Mastra with automatic or manual embedding, metadata filtering, hybrid search, and indexing of existing collections.
|
|
26
27
|
|
|
27
28
|
### Reference
|
|
28
29
|
|
|
@@ -30,7 +31,6 @@ Read the individual reference documents for detailed explanations and code examp
|
|
|
30
31
|
- [Storing embeddings in a vector database](references/reference-rag-vector-databases.md) - After generating embeddings, you need to store them in a database that supports vector similarity search.
|
|
31
32
|
- [Reference: Composite storage](references/reference-storage-composite.md) - MastraCompositeStore can compose storage domains from different providers. Use it when you need different databases for different purposes.
|
|
32
33
|
- [Reference: Storage retention (prune)](references/reference-storage-retention.md) - prune() deletes rows. It caps growth and is safe to run against large tables (batched, bounded, resumable, cancellable).
|
|
33
|
-
- [Reference: MongoDB vector store](references/reference-vectors-mongodb.md) - The MongoDBVector class provides vector search using MongoDB Vector Search. It enables efficient similarity search and metadata filtering within your MongoDB collections.
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
Read [assets/SOURCE_MAP.json](assets/SOURCE_MAP.json) for source code references.
|
|
@@ -141,24 +141,24 @@ const agent = new Agent({
|
|
|
141
141
|
|
|
142
142
|
Each vector store page below includes installation instructions, configuration parameters, and usage examples:
|
|
143
143
|
|
|
144
|
-
- [Astra](https://mastra.ai/
|
|
145
|
-
- [Chroma](https://mastra.ai/
|
|
146
|
-
- [Cloudflare Vectorize](https://mastra.ai/
|
|
147
|
-
- [Convex](https://mastra.ai/
|
|
148
|
-
- [Couchbase](https://mastra.ai/
|
|
149
|
-
- [DuckDB](https://mastra.ai/
|
|
150
|
-
- [Elasticsearch](https://mastra.ai/
|
|
151
|
-
- [LanceDB](https://mastra.ai/
|
|
152
|
-
- [libSQL](https://mastra.ai/
|
|
153
|
-
- [MongoDB](https://mastra.ai/
|
|
154
|
-
- [OpenSearch](https://mastra.ai/
|
|
155
|
-
- [OracleDB](https://mastra.ai/
|
|
156
|
-
- [Pinecone](https://mastra.ai/
|
|
157
|
-
- [PostgreSQL](https://mastra.ai/
|
|
158
|
-
- [Qdrant](https://mastra.ai/
|
|
159
|
-
- [S3 Vectors](https://mastra.ai/
|
|
160
|
-
- [Turbopuffer](https://mastra.ai/
|
|
161
|
-
- [Upstash](https://mastra.ai/
|
|
144
|
+
- [Astra](https://mastra.ai/integrations/vectors/astra)
|
|
145
|
+
- [Chroma](https://mastra.ai/integrations/vectors/chroma)
|
|
146
|
+
- [Cloudflare Vectorize](https://mastra.ai/integrations/vectors/vectorize)
|
|
147
|
+
- [Convex](https://mastra.ai/integrations/vectors/convex)
|
|
148
|
+
- [Couchbase](https://mastra.ai/integrations/vectors/couchbase)
|
|
149
|
+
- [DuckDB](https://mastra.ai/integrations/vectors/duckdb)
|
|
150
|
+
- [Elasticsearch](https://mastra.ai/integrations/vectors/elasticsearch)
|
|
151
|
+
- [LanceDB](https://mastra.ai/integrations/vectors/lance)
|
|
152
|
+
- [libSQL](https://mastra.ai/integrations/vectors/libsql)
|
|
153
|
+
- [MongoDB](https://mastra.ai/integrations/vectors/mongodb)
|
|
154
|
+
- [OpenSearch](https://mastra.ai/integrations/vectors/opensearch)
|
|
155
|
+
- [OracleDB](https://mastra.ai/integrations/vectors/oracledb)
|
|
156
|
+
- [Pinecone](https://mastra.ai/integrations/vectors/pinecone)
|
|
157
|
+
- [PostgreSQL](https://mastra.ai/integrations/vectors/pg)
|
|
158
|
+
- [Qdrant](https://mastra.ai/integrations/vectors/qdrant)
|
|
159
|
+
- [S3 Vectors](https://mastra.ai/integrations/vectors/s3vectors)
|
|
160
|
+
- [Turbopuffer](https://mastra.ai/integrations/vectors/turbopuffer)
|
|
161
|
+
- [Upstash](https://mastra.ai/integrations/vectors/upstash)
|
|
162
162
|
|
|
163
163
|
## Recall configuration
|
|
164
164
|
|
|
@@ -250,7 +250,7 @@ const options = {
|
|
|
250
250
|
|
|
251
251
|
Some vector stores generate the embeddings themselves. With one of those, semantic recall runs without an `embedder`: the database embeds each message on write and the search string on arrival. The embedding provider stays out of your application entirely.
|
|
252
252
|
|
|
253
|
-
MongoDB does this through [Automated Embedding](https://mastra.ai/
|
|
253
|
+
MongoDB does this through [Automated Embedding](https://mastra.ai/integrations/vectors/mongodb): name a Voyage AI model on the vector store and leave the `embedder` out.
|
|
254
254
|
|
|
255
255
|
```typescript
|
|
256
256
|
import { Memory } from '@mastra/memory'
|
|
@@ -467,7 +467,7 @@ const agent = new Agent({
|
|
|
467
467
|
})
|
|
468
468
|
```
|
|
469
469
|
|
|
470
|
-
For detailed information about index configuration options and performance tuning, see the [PgVector configuration guide](https://mastra.ai/
|
|
470
|
+
For detailed information about index configuration options and performance tuning, see the [PgVector configuration guide](https://mastra.ai/integrations/vectors/pg).
|
|
471
471
|
|
|
472
472
|
## Disable semantic recall
|
|
473
473
|
|
|
@@ -194,7 +194,7 @@ await storage.close()
|
|
|
194
194
|
|
|
195
195
|
## Vector search capabilities
|
|
196
196
|
|
|
197
|
-
MongoDB storage includes built-in vector search capabilities for AI applications. For detailed vector operations including index creation, upserting embeddings, similarity search, and metadata filtering, see the [MongoDB vector reference](https://mastra.ai/
|
|
197
|
+
MongoDB storage includes built-in vector search capabilities for AI applications. For detailed vector operations including index creation, upserting embeddings, similarity search, and metadata filtering, see the [MongoDB vector reference](https://mastra.ai/integrations/vectors/mongodb).
|
|
198
198
|
|
|
199
199
|
## Usage example
|
|
200
200
|
|
package/dist/docs/references/{reference-vectors-mongodb.md → integrations-vectors-mongodb.md}
RENAMED
|
@@ -71,6 +71,8 @@ const store = new MongoDBVector({
|
|
|
71
71
|
|
|
72
72
|
**embeddingFieldPath** (`string`): Path to the field that stores vector embeddings. Supports nested paths using dot notation (e.g., 'text.contentEmbedding'). (Default: `embedding`)
|
|
73
73
|
|
|
74
|
+
**autoEmbed** (`MongoDBAutoEmbedConfig`): Automated Embedding defaults for indexes this store creates, such as { model: 'voyage-4' }. An index created without its own autoEmbed or dimension uses these settings, which makes the store embed text server-side instead of receiving vectors.
|
|
75
|
+
|
|
74
76
|
## Methods
|
|
75
77
|
|
|
76
78
|
### `connect()`
|
|
@@ -35,7 +35,7 @@ MongoDB Vector Search is a good solution for teams who want to consolidate vecto
|
|
|
35
35
|
|
|
36
36
|
### Using VoyageAI with MongoDB
|
|
37
37
|
|
|
38
|
-
MongoDB works directly with VoyageAI's embedding models, which are optimized for retrieval tasks. For complete examples and specialized models, see the [VoyageAI embeddings documentation](https://mastra.ai/models/embeddings) and [MongoDB vector reference](https://mastra.ai/
|
|
38
|
+
MongoDB works directly with VoyageAI's embedding models, which are optimized for retrieval tasks. For complete examples and specialized models, see the [VoyageAI embeddings documentation](https://mastra.ai/models/embeddings) and [MongoDB vector reference](https://mastra.ai/integrations/vectors/mongodb).
|
|
39
39
|
|
|
40
40
|
### Hybrid Search (Vector + Full-Text)
|
|
41
41
|
|
|
@@ -52,7 +52,7 @@ const results = await store.hybridQuery({
|
|
|
52
52
|
})
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
-
See the [MongoDB vector reference](https://mastra.ai/
|
|
55
|
+
See the [MongoDB vector reference](https://mastra.ai/integrations/vectors/mongodb) for details on `createSearchIndex()`, `textQuery()`, and `hybridQuery()`.
|
|
56
56
|
|
|
57
57
|
### Automated Embedding
|
|
58
58
|
|
|
@@ -75,7 +75,7 @@ const results = await store.query({
|
|
|
75
75
|
})
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
-
Automated Embedding is a MongoDB Preview feature and needs a deployment where it's available. See the [MongoDB vector reference](https://mastra.ai/
|
|
78
|
+
Automated Embedding is a MongoDB Preview feature and needs a deployment where it's available. See the [MongoDB vector reference](https://mastra.ai/integrations/vectors/mongodb) for the supported options and requirements.
|
|
79
79
|
|
|
80
80
|
**PgVector**:
|
|
81
81
|
|
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
|
// package.json
|
|
13
|
-
var version = "1.
|
|
13
|
+
var version = "1.25.0-alpha.0";
|
|
14
14
|
// src/vector/filter.ts
|
|
15
15
|
/**
|
|
16
16
|
* Translator for MongoDB filter queries.
|
|
@@ -2440,7 +2440,9 @@ function toDoc(task) {
|
|
|
2440
2440
|
suspendedAt: task.suspendedAt?.toISOString() ?? null,
|
|
2441
2441
|
completedAt: task.completedAt?.toISOString() ?? null,
|
|
2442
2442
|
ownerId: task.ownerId ?? null,
|
|
2443
|
-
leaseExpiresAt: task.leaseExpiresAt?.toISOString() ?? null
|
|
2443
|
+
leaseExpiresAt: task.leaseExpiresAt?.toISOString() ?? null,
|
|
2444
|
+
expiresAt: task.expiresAt?.toISOString() ?? null,
|
|
2445
|
+
metadata: task.metadata ?? null
|
|
2444
2446
|
};
|
|
2445
2447
|
}
|
|
2446
2448
|
function fromDoc(doc) {
|
|
@@ -2465,10 +2467,13 @@ function fromDoc(doc) {
|
|
|
2465
2467
|
suspendedAt: doc.suspendedAt ? new Date(doc.suspendedAt) : void 0,
|
|
2466
2468
|
completedAt: doc.completedAt ? new Date(doc.completedAt) : void 0,
|
|
2467
2469
|
ownerId: doc.ownerId ?? void 0,
|
|
2468
|
-
leaseExpiresAt: doc.leaseExpiresAt ? new Date(doc.leaseExpiresAt) : void 0
|
|
2470
|
+
leaseExpiresAt: doc.leaseExpiresAt ? new Date(doc.leaseExpiresAt) : void 0,
|
|
2471
|
+
expiresAt: doc.expiresAt ? new Date(doc.expiresAt) : void 0,
|
|
2472
|
+
metadata: doc.metadata ?? void 0
|
|
2469
2473
|
};
|
|
2470
2474
|
}
|
|
2471
2475
|
var BackgroundTasksStorageMongoDB = class BackgroundTasksStorageMongoDB extends _mastra_core_storage.BackgroundTasksStorage {
|
|
2476
|
+
supportsTaskExpiry = true;
|
|
2472
2477
|
#connector;
|
|
2473
2478
|
#skipDefaultIndexes;
|
|
2474
2479
|
#indexes;
|
|
@@ -2584,11 +2589,14 @@ var BackgroundTasksStorageMongoDB = class BackgroundTasksStorageMongoDB extends
|
|
|
2584
2589
|
if ("completedAt" in update) $set.completedAt = update.completedAt?.toISOString() ?? null;
|
|
2585
2590
|
if ("ownerId" in update) $set.ownerId = update.ownerId ?? null;
|
|
2586
2591
|
if ("leaseExpiresAt" in update) $set.leaseExpiresAt = update.leaseExpiresAt?.toISOString() ?? null;
|
|
2592
|
+
if ("expiresAt" in update) $set.expiresAt = update.expiresAt?.toISOString() ?? null;
|
|
2593
|
+
if ("metadata" in update) $set.metadata = update.metadata ?? null;
|
|
2587
2594
|
if (Object.keys($set).length === 0) return false;
|
|
2588
2595
|
const filter = { id: taskId };
|
|
2589
2596
|
if (options?.expectedStatus) filter.status = options.expectedStatus;
|
|
2590
2597
|
if (options?.expectedOwnerId !== void 0) filter.ownerId = options.expectedOwnerId;
|
|
2591
2598
|
if (options?.expectedLeaseExpiresAt !== void 0) filter.leaseExpiresAt = options.expectedLeaseExpiresAt?.toISOString() ?? null;
|
|
2599
|
+
if (options?.expectedSuspendedAt !== void 0) filter.suspendedAt = options.expectedSuspendedAt?.toISOString() ?? null;
|
|
2592
2600
|
return (await (await this.getCollection()).updateOne(filter, { $set })).matchedCount > 0;
|
|
2593
2601
|
}
|
|
2594
2602
|
async getTask(taskId) {
|
|
@@ -2607,7 +2615,8 @@ var BackgroundTasksStorageMongoDB = class BackgroundTasksStorageMongoDB extends
|
|
|
2607
2615
|
if (filter.runId) query.run_id = filter.runId;
|
|
2608
2616
|
if (filter.toolName) query.tool_name = filter.toolName;
|
|
2609
2617
|
if (filter.toolCallId) query.tool_call_id = filter.toolCallId;
|
|
2610
|
-
const dateCol = filter.dateFilterBy === "startedAt" ? "startedAt" : filter.dateFilterBy === "suspendedAt" ? "suspendedAt" : filter.dateFilterBy === "completedAt" ? "completedAt" : "createdAt";
|
|
2618
|
+
const dateCol = filter.dateFilterBy === "startedAt" ? "startedAt" : filter.dateFilterBy === "suspendedAt" ? "suspendedAt" : filter.dateFilterBy === "completedAt" ? "completedAt" : filter.dateFilterBy === "expiresAt" ? "expiresAt" : "createdAt";
|
|
2619
|
+
if (filter.hasExpiresAt !== void 0) query.expiresAt = filter.hasExpiresAt ? { $ne: null } : { $eq: null };
|
|
2611
2620
|
if (filter.fromDate) query[dateCol] = {
|
|
2612
2621
|
...query[dateCol] || {},
|
|
2613
2622
|
$gte: filter.fromDate.toISOString()
|
|
@@ -2639,7 +2648,8 @@ var BackgroundTasksStorageMongoDB = class BackgroundTasksStorageMongoDB extends
|
|
|
2639
2648
|
const statuses = Array.isArray(filter.status) ? filter.status : [filter.status];
|
|
2640
2649
|
query.status = statuses.length === 1 ? statuses[0] : { $in: statuses };
|
|
2641
2650
|
}
|
|
2642
|
-
const dateCol = filter.dateFilterBy === "startedAt" ? "startedAt" : filter.dateFilterBy === "suspendedAt" ? "suspendedAt" : filter.dateFilterBy === "completedAt" ? "completedAt" : "createdAt";
|
|
2651
|
+
const dateCol = filter.dateFilterBy === "startedAt" ? "startedAt" : filter.dateFilterBy === "suspendedAt" ? "suspendedAt" : filter.dateFilterBy === "completedAt" ? "completedAt" : filter.dateFilterBy === "expiresAt" ? "expiresAt" : "createdAt";
|
|
2652
|
+
if (filter.hasExpiresAt !== void 0) query.expiresAt = filter.hasExpiresAt ? { $ne: null } : { $eq: null };
|
|
2643
2653
|
if (filter.fromDate) query[dateCol] = {
|
|
2644
2654
|
...query[dateCol] || {},
|
|
2645
2655
|
$gte: filter.fromDate.toISOString()
|