@mastra/mongodb 0.11.1-alpha.0 → 0.11.1-alpha.2
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/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +28 -0
- package/dist/_tsup-dts-rollup.d.cts +17 -7
- package/dist/_tsup-dts-rollup.d.ts +17 -7
- package/dist/index.cjs +560 -226
- package/dist/index.d.cts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +539 -205
- package/package.json +4 -4
- package/src/storage/index.test.ts +239 -4
- package/src/storage/index.ts +295 -106
- package/src/vector/filter.test.ts +40 -30
- package/src/vector/filter.ts +25 -4
- package/src/vector/index.test.ts +1 -2
- package/src/vector/index.ts +275 -130
package/src/vector/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MastraError, ErrorDomain, ErrorCategory } from '@mastra/core/error';
|
|
1
2
|
import { MastraVector } from '@mastra/core/vector';
|
|
2
3
|
import type {
|
|
3
4
|
QueryResult,
|
|
@@ -10,20 +11,20 @@ import type {
|
|
|
10
11
|
DeleteVectorParams,
|
|
11
12
|
UpdateVectorParams,
|
|
12
13
|
} from '@mastra/core/vector';
|
|
13
|
-
import type { VectorFilter } from '@mastra/core/vector/filter';
|
|
14
14
|
import { MongoClient } from 'mongodb';
|
|
15
15
|
import type { MongoClientOptions, Document, Db, Collection } from 'mongodb';
|
|
16
16
|
import { v4 as uuidv4 } from 'uuid';
|
|
17
17
|
|
|
18
18
|
import { MongoDBFilterTranslator } from './filter';
|
|
19
|
+
import type { MongoDBVectorFilter } from './filter';
|
|
19
20
|
|
|
20
21
|
// Define necessary types and interfaces
|
|
21
22
|
export interface MongoDBUpsertVectorParams extends UpsertVectorParams {
|
|
22
23
|
documents?: string[];
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
documentFilter?:
|
|
26
|
+
interface MongoDBQueryVectorParams extends QueryVectorParams<MongoDBVectorFilter> {
|
|
27
|
+
documentFilter?: MongoDBVectorFilter;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
export interface MongoDBIndexReadyParams {
|
|
@@ -41,7 +42,7 @@ interface MongoDBDocument extends Document {
|
|
|
41
42
|
[key: string]: any; // Index signature for additional properties
|
|
42
43
|
}
|
|
43
44
|
// The MongoDBVector class
|
|
44
|
-
export class MongoDBVector extends MastraVector {
|
|
45
|
+
export class MongoDBVector extends MastraVector<MongoDBVectorFilter> {
|
|
45
46
|
private client: MongoClient;
|
|
46
47
|
private db: Db;
|
|
47
48
|
private collections: Map<string, Collection<MongoDBDocument>>;
|
|
@@ -64,36 +65,76 @@ export class MongoDBVector extends MastraVector {
|
|
|
64
65
|
|
|
65
66
|
// Public methods
|
|
66
67
|
async connect(): Promise<void> {
|
|
67
|
-
|
|
68
|
+
try {
|
|
69
|
+
await this.client.connect();
|
|
70
|
+
} catch (error) {
|
|
71
|
+
throw new MastraError(
|
|
72
|
+
{
|
|
73
|
+
id: 'STORAGE_MONGODB_VECTOR_CONNECT_FAILED',
|
|
74
|
+
domain: ErrorDomain.STORAGE,
|
|
75
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
76
|
+
},
|
|
77
|
+
error,
|
|
78
|
+
);
|
|
79
|
+
}
|
|
68
80
|
}
|
|
69
81
|
|
|
70
82
|
async disconnect(): Promise<void> {
|
|
71
|
-
|
|
83
|
+
try {
|
|
84
|
+
await this.client.close();
|
|
85
|
+
} catch (error) {
|
|
86
|
+
throw new MastraError(
|
|
87
|
+
{
|
|
88
|
+
id: 'STORAGE_MONGODB_VECTOR_DISCONNECT_FAILED',
|
|
89
|
+
domain: ErrorDomain.STORAGE,
|
|
90
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
91
|
+
},
|
|
92
|
+
error,
|
|
93
|
+
);
|
|
94
|
+
}
|
|
72
95
|
}
|
|
73
96
|
|
|
74
97
|
async createIndex({ indexName, dimension, metric = 'cosine' }: CreateIndexParams): Promise<void> {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
98
|
+
let mongoMetric;
|
|
99
|
+
try {
|
|
100
|
+
if (!Number.isInteger(dimension) || dimension <= 0) {
|
|
101
|
+
throw new Error('Dimension must be a positive integer');
|
|
102
|
+
}
|
|
78
103
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
104
|
+
mongoMetric = this.mongoMetricMap[metric];
|
|
105
|
+
if (!mongoMetric) {
|
|
106
|
+
throw new Error(`Invalid metric: "${metric}". Must be one of: cosine, euclidean, dotproduct`);
|
|
107
|
+
}
|
|
108
|
+
} catch (error) {
|
|
109
|
+
throw new MastraError(
|
|
110
|
+
{
|
|
111
|
+
id: 'STORAGE_MONGODB_VECTOR_CREATE_INDEX_INVALID_ARGS',
|
|
112
|
+
domain: ErrorDomain.STORAGE,
|
|
113
|
+
category: ErrorCategory.USER,
|
|
114
|
+
details: {
|
|
115
|
+
indexName,
|
|
116
|
+
dimension,
|
|
117
|
+
metric,
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
error,
|
|
121
|
+
);
|
|
82
122
|
}
|
|
83
123
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
await this.db.
|
|
88
|
-
|
|
89
|
-
|
|
124
|
+
let collection;
|
|
125
|
+
try {
|
|
126
|
+
// Check if collection exists
|
|
127
|
+
const collectionExists = await this.db.listCollections({ name: indexName }).hasNext();
|
|
128
|
+
if (!collectionExists) {
|
|
129
|
+
await this.db.createCollection(indexName);
|
|
130
|
+
}
|
|
131
|
+
collection = await this.getCollection(indexName);
|
|
90
132
|
|
|
91
|
-
|
|
133
|
+
const indexNameInternal = `${indexName}_vector_index`;
|
|
92
134
|
|
|
93
|
-
|
|
94
|
-
|
|
135
|
+
const embeddingField = this.embeddingFieldName;
|
|
136
|
+
const numDimensions = dimension;
|
|
95
137
|
|
|
96
|
-
try {
|
|
97
138
|
// Create the search index
|
|
98
139
|
await (collection as any).createSearchIndex({
|
|
99
140
|
definition: {
|
|
@@ -111,12 +152,33 @@ export class MongoDBVector extends MastraVector {
|
|
|
111
152
|
});
|
|
112
153
|
} catch (error: any) {
|
|
113
154
|
if (error.codeName !== 'IndexAlreadyExists') {
|
|
114
|
-
throw
|
|
155
|
+
throw new MastraError(
|
|
156
|
+
{
|
|
157
|
+
id: 'STORAGE_MONGODB_VECTOR_CREATE_INDEX_FAILED',
|
|
158
|
+
domain: ErrorDomain.STORAGE,
|
|
159
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
160
|
+
},
|
|
161
|
+
error,
|
|
162
|
+
);
|
|
115
163
|
}
|
|
116
164
|
}
|
|
117
165
|
|
|
118
|
-
|
|
119
|
-
|
|
166
|
+
try {
|
|
167
|
+
// Store the dimension and metric in a special metadata document
|
|
168
|
+
await collection?.updateOne({ _id: '__index_metadata__' }, { $set: { dimension, metric } }, { upsert: true });
|
|
169
|
+
} catch (error) {
|
|
170
|
+
throw new MastraError(
|
|
171
|
+
{
|
|
172
|
+
id: 'STORAGE_MONGODB_VECTOR_CREATE_INDEX_FAILED_STORE_METADATA',
|
|
173
|
+
domain: ErrorDomain.STORAGE,
|
|
174
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
175
|
+
details: {
|
|
176
|
+
indexName,
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
error,
|
|
180
|
+
);
|
|
181
|
+
}
|
|
120
182
|
}
|
|
121
183
|
|
|
122
184
|
/**
|
|
@@ -149,55 +211,68 @@ export class MongoDBVector extends MastraVector {
|
|
|
149
211
|
}
|
|
150
212
|
|
|
151
213
|
async upsert({ indexName, vectors, metadata, ids, documents }: MongoDBUpsertVectorParams): Promise<string[]> {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
this.collectionForValidation = collection;
|
|
214
|
+
try {
|
|
215
|
+
const collection = await this.getCollection(indexName);
|
|
155
216
|
|
|
156
|
-
|
|
157
|
-
const stats = await this.describeIndex({ indexName });
|
|
217
|
+
this.collectionForValidation = collection;
|
|
158
218
|
|
|
159
|
-
|
|
160
|
-
|
|
219
|
+
// Get index stats to check dimension
|
|
220
|
+
const stats = await this.describeIndex({ indexName });
|
|
161
221
|
|
|
162
|
-
|
|
163
|
-
|
|
222
|
+
// Validate vector dimensions
|
|
223
|
+
await this.validateVectorDimensions(vectors, stats.dimension);
|
|
164
224
|
|
|
165
|
-
|
|
166
|
-
const
|
|
167
|
-
const meta = metadata?.[idx] || {};
|
|
168
|
-
const doc = documents?.[idx];
|
|
225
|
+
// Generate IDs if not provided
|
|
226
|
+
const generatedIds = ids || vectors.map(() => uuidv4());
|
|
169
227
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
return acc;
|
|
175
|
-
},
|
|
176
|
-
{} as Record<string, any>,
|
|
177
|
-
);
|
|
228
|
+
const operations = vectors.map((vector, idx) => {
|
|
229
|
+
const id = generatedIds[idx];
|
|
230
|
+
const meta = metadata?.[idx] || {};
|
|
231
|
+
const doc = documents?.[idx];
|
|
178
232
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
233
|
+
// Normalize metadata - convert Date objects to ISO strings
|
|
234
|
+
const normalizedMeta = Object.keys(meta).reduce(
|
|
235
|
+
(acc, key) => {
|
|
236
|
+
acc[key] = meta[key] instanceof Date ? meta[key].toISOString() : meta[key];
|
|
237
|
+
return acc;
|
|
238
|
+
},
|
|
239
|
+
{} as Record<string, any>,
|
|
240
|
+
);
|
|
186
241
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
242
|
+
const updateDoc: Partial<MongoDBDocument> = {
|
|
243
|
+
[this.embeddingFieldName]: vector,
|
|
244
|
+
[this.metadataFieldName]: normalizedMeta,
|
|
245
|
+
};
|
|
246
|
+
if (doc !== undefined) {
|
|
247
|
+
updateDoc[this.documentFieldName] = doc;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return {
|
|
251
|
+
updateOne: {
|
|
252
|
+
filter: { _id: id }, // '_id' is a string as per MongoDBDocument interface
|
|
253
|
+
update: { $set: updateDoc },
|
|
254
|
+
upsert: true,
|
|
255
|
+
},
|
|
256
|
+
};
|
|
257
|
+
});
|
|
195
258
|
|
|
196
|
-
|
|
259
|
+
await collection.bulkWrite(operations);
|
|
197
260
|
|
|
198
|
-
|
|
261
|
+
return generatedIds;
|
|
262
|
+
} catch (error) {
|
|
263
|
+
throw new MastraError(
|
|
264
|
+
{
|
|
265
|
+
id: 'STORAGE_MONGODB_VECTOR_UPSERT_FAILED',
|
|
266
|
+
domain: ErrorDomain.STORAGE,
|
|
267
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
268
|
+
details: {
|
|
269
|
+
indexName,
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
error,
|
|
273
|
+
);
|
|
274
|
+
}
|
|
199
275
|
}
|
|
200
|
-
|
|
201
276
|
async query({
|
|
202
277
|
indexName,
|
|
203
278
|
queryVector,
|
|
@@ -206,51 +281,51 @@ export class MongoDBVector extends MastraVector {
|
|
|
206
281
|
includeVector = false,
|
|
207
282
|
documentFilter,
|
|
208
283
|
}: MongoDBQueryVectorParams): Promise<QueryResult[]> {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
284
|
+
try {
|
|
285
|
+
const collection = await this.getCollection(indexName, true);
|
|
286
|
+
const indexNameInternal = `${indexName}_vector_index`;
|
|
287
|
+
|
|
288
|
+
// Transform the filters using MongoDBFilterTranslator
|
|
289
|
+
const mongoFilter = this.transformFilter(filter);
|
|
290
|
+
const documentMongoFilter = documentFilter ? { [this.documentFieldName]: documentFilter } : {};
|
|
291
|
+
|
|
292
|
+
// Combine the filters
|
|
293
|
+
let combinedFilter: any = {};
|
|
294
|
+
if (Object.keys(mongoFilter).length > 0 && Object.keys(documentMongoFilter).length > 0) {
|
|
295
|
+
combinedFilter = { $and: [mongoFilter, documentMongoFilter] };
|
|
296
|
+
} else if (Object.keys(mongoFilter).length > 0) {
|
|
297
|
+
combinedFilter = mongoFilter;
|
|
298
|
+
} else if (Object.keys(documentMongoFilter).length > 0) {
|
|
299
|
+
combinedFilter = documentMongoFilter;
|
|
300
|
+
}
|
|
225
301
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
302
|
+
// Build the aggregation pipeline
|
|
303
|
+
const pipeline = [
|
|
304
|
+
{
|
|
305
|
+
$vectorSearch: {
|
|
306
|
+
index: indexNameInternal,
|
|
307
|
+
queryVector: queryVector,
|
|
308
|
+
path: this.embeddingFieldName,
|
|
309
|
+
numCandidates: 100,
|
|
310
|
+
limit: topK,
|
|
311
|
+
},
|
|
312
|
+
},
|
|
313
|
+
// Apply the filter using $match stage
|
|
314
|
+
...(Object.keys(combinedFilter).length > 0 ? [{ $match: combinedFilter }] : []),
|
|
315
|
+
{
|
|
316
|
+
$set: { score: { $meta: 'vectorSearchScore' } },
|
|
235
317
|
},
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
_id: 1,
|
|
245
|
-
score: 1,
|
|
246
|
-
metadata: `$${this.metadataFieldName}`,
|
|
247
|
-
document: `$${this.documentFieldName}`,
|
|
248
|
-
...(includeVector && { vector: `$${this.embeddingFieldName}` }),
|
|
318
|
+
{
|
|
319
|
+
$project: {
|
|
320
|
+
_id: 1,
|
|
321
|
+
score: 1,
|
|
322
|
+
metadata: `$${this.metadataFieldName}`,
|
|
323
|
+
document: `$${this.documentFieldName}`,
|
|
324
|
+
...(includeVector && { vector: `$${this.embeddingFieldName}` }),
|
|
325
|
+
},
|
|
249
326
|
},
|
|
250
|
-
|
|
251
|
-
];
|
|
327
|
+
];
|
|
252
328
|
|
|
253
|
-
try {
|
|
254
329
|
const results = await collection.aggregate(pipeline).toArray();
|
|
255
330
|
|
|
256
331
|
return results.map((result: any) => ({
|
|
@@ -261,14 +336,34 @@ export class MongoDBVector extends MastraVector {
|
|
|
261
336
|
document: result.document,
|
|
262
337
|
}));
|
|
263
338
|
} catch (error) {
|
|
264
|
-
|
|
265
|
-
|
|
339
|
+
throw new MastraError(
|
|
340
|
+
{
|
|
341
|
+
id: 'STORAGE_MONGODB_VECTOR_QUERY_FAILED',
|
|
342
|
+
domain: ErrorDomain.STORAGE,
|
|
343
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
344
|
+
details: {
|
|
345
|
+
indexName,
|
|
346
|
+
},
|
|
347
|
+
},
|
|
348
|
+
error,
|
|
349
|
+
);
|
|
266
350
|
}
|
|
267
351
|
}
|
|
268
352
|
|
|
269
353
|
async listIndexes(): Promise<string[]> {
|
|
270
|
-
|
|
271
|
-
|
|
354
|
+
try {
|
|
355
|
+
const collections = await this.db.listCollections().toArray();
|
|
356
|
+
return collections.map(col => col.name);
|
|
357
|
+
} catch (error) {
|
|
358
|
+
throw new MastraError(
|
|
359
|
+
{
|
|
360
|
+
id: 'STORAGE_MONGODB_VECTOR_LIST_INDEXES_FAILED',
|
|
361
|
+
domain: ErrorDomain.STORAGE,
|
|
362
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
363
|
+
},
|
|
364
|
+
error,
|
|
365
|
+
);
|
|
366
|
+
}
|
|
272
367
|
}
|
|
273
368
|
|
|
274
369
|
/**
|
|
@@ -278,31 +373,59 @@ export class MongoDBVector extends MastraVector {
|
|
|
278
373
|
* @returns A promise that resolves to the index statistics including dimension, count and metric
|
|
279
374
|
*/
|
|
280
375
|
async describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats> {
|
|
281
|
-
|
|
376
|
+
try {
|
|
377
|
+
const collection = await this.getCollection(indexName, true);
|
|
282
378
|
|
|
283
|
-
|
|
284
|
-
|
|
379
|
+
// Get the count of documents, excluding the metadata document
|
|
380
|
+
const count = await collection.countDocuments({ _id: { $ne: '__index_metadata__' } });
|
|
285
381
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
382
|
+
// Retrieve the dimension and metric from the metadata document
|
|
383
|
+
const metadataDoc = await collection.findOne({ _id: '__index_metadata__' });
|
|
384
|
+
const dimension = metadataDoc?.dimension || 0;
|
|
385
|
+
const metric = metadataDoc?.metric || 'cosine';
|
|
290
386
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
387
|
+
return {
|
|
388
|
+
dimension,
|
|
389
|
+
count,
|
|
390
|
+
metric: metric as 'cosine' | 'euclidean' | 'dotproduct',
|
|
391
|
+
};
|
|
392
|
+
} catch (error) {
|
|
393
|
+
throw new MastraError(
|
|
394
|
+
{
|
|
395
|
+
id: 'STORAGE_MONGODB_VECTOR_DESCRIBE_INDEX_FAILED',
|
|
396
|
+
domain: ErrorDomain.STORAGE,
|
|
397
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
398
|
+
details: {
|
|
399
|
+
indexName,
|
|
400
|
+
},
|
|
401
|
+
},
|
|
402
|
+
error,
|
|
403
|
+
);
|
|
404
|
+
}
|
|
296
405
|
}
|
|
297
406
|
|
|
298
407
|
async deleteIndex({ indexName }: DeleteIndexParams): Promise<void> {
|
|
299
408
|
const collection = await this.getCollection(indexName, false); // Do not throw error if collection doesn't exist
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
409
|
+
try {
|
|
410
|
+
if (collection) {
|
|
411
|
+
await collection.drop();
|
|
412
|
+
this.collections.delete(indexName);
|
|
413
|
+
} else {
|
|
414
|
+
// Optionally, you can log or handle the case where the collection doesn't exist
|
|
415
|
+
throw new Error(`Index (Collection) "${indexName}" does not exist`);
|
|
416
|
+
}
|
|
417
|
+
} catch (error) {
|
|
418
|
+
throw new MastraError(
|
|
419
|
+
{
|
|
420
|
+
id: 'STORAGE_MONGODB_VECTOR_DELETE_INDEX_FAILED',
|
|
421
|
+
domain: ErrorDomain.STORAGE,
|
|
422
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
423
|
+
details: {
|
|
424
|
+
indexName,
|
|
425
|
+
},
|
|
426
|
+
},
|
|
427
|
+
error,
|
|
428
|
+
);
|
|
306
429
|
}
|
|
307
430
|
}
|
|
308
431
|
|
|
@@ -347,7 +470,18 @@ export class MongoDBVector extends MastraVector {
|
|
|
347
470
|
|
|
348
471
|
await collection.findOneAndUpdate({ _id: id }, { $set: updateDoc });
|
|
349
472
|
} catch (error: any) {
|
|
350
|
-
throw new
|
|
473
|
+
throw new MastraError(
|
|
474
|
+
{
|
|
475
|
+
id: 'STORAGE_MONGODB_VECTOR_UPDATE_VECTOR_FAILED',
|
|
476
|
+
domain: ErrorDomain.STORAGE,
|
|
477
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
478
|
+
details: {
|
|
479
|
+
indexName,
|
|
480
|
+
id,
|
|
481
|
+
},
|
|
482
|
+
},
|
|
483
|
+
error,
|
|
484
|
+
);
|
|
351
485
|
}
|
|
352
486
|
}
|
|
353
487
|
|
|
@@ -363,7 +497,18 @@ export class MongoDBVector extends MastraVector {
|
|
|
363
497
|
const collection = await this.getCollection(indexName, true);
|
|
364
498
|
await collection.deleteOne({ _id: id });
|
|
365
499
|
} catch (error: any) {
|
|
366
|
-
throw new
|
|
500
|
+
throw new MastraError(
|
|
501
|
+
{
|
|
502
|
+
id: 'STORAGE_MONGODB_VECTOR_DELETE_VECTOR_FAILED',
|
|
503
|
+
domain: ErrorDomain.STORAGE,
|
|
504
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
505
|
+
details: {
|
|
506
|
+
indexName,
|
|
507
|
+
id,
|
|
508
|
+
},
|
|
509
|
+
},
|
|
510
|
+
error,
|
|
511
|
+
);
|
|
367
512
|
}
|
|
368
513
|
}
|
|
369
514
|
|
|
@@ -413,7 +558,7 @@ export class MongoDBVector extends MastraVector {
|
|
|
413
558
|
await collection.updateOne({ _id: '__index_metadata__' }, { $set: { dimension } }, { upsert: true });
|
|
414
559
|
}
|
|
415
560
|
|
|
416
|
-
private transformFilter(filter?:
|
|
561
|
+
private transformFilter(filter?: MongoDBVectorFilter) {
|
|
417
562
|
const translator = new MongoDBFilterTranslator();
|
|
418
563
|
if (!filter) return {};
|
|
419
564
|
return translator.translate(filter);
|