@mastra/mongodb 0.0.2-alpha.2 → 0.0.2-alpha.4

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.0.2-alpha.2 build /home/runner/work/mastra/mastra/stores/mongodb
2
+ > @mastra/mongodb@0.0.2-alpha.4 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.4.0
8
8
  TSC Build start
9
- TSC ⚡️ Build success in 8226ms
9
+ TSC ⚡️ Build success in 7155ms
10
10
  DTS Build start
11
11
  CLI Target: es2022
12
- Analysis will use the bundled TypeScript version 5.8.2
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
- Analysis will use the bundled TypeScript version 5.8.2
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 9773ms
16
+ DTS ⚡️ Build success in 9430ms
17
17
  CLI Cleaning output folder
18
18
  ESM Build start
19
19
  CJS Build start
20
- CJS dist/index.cjs 12.33 KB
21
- CJS ⚡️ Build success in 633ms
22
- ESM dist/index.js 12.29 KB
23
- ESM ⚡️ Build success in 634ms
20
+ ESM dist/index.js 16.22 KB
21
+ ESM ⚡️ Build success in 751ms
22
+ CJS dist/index.cjs 16.28 KB
23
+ CJS ⚡️ Build success in 751ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @mastra/mongodb
2
2
 
3
+ ## 0.0.2-alpha.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 5f826d9: Moved vector store specific prompts from @mastra/rag to be exported from the store that the prompt belongs to, ie @mastra/pg
8
+ - Updated dependencies [3e7b69d]
9
+ - @mastra/core@0.9.1-alpha.5
10
+
11
+ ## 0.0.2-alpha.3
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [e4943b8]
16
+ - Updated dependencies [479f490]
17
+ - @mastra/core@0.9.1-alpha.4
18
+
3
19
  ## 0.0.2-alpha.2
4
20
 
5
21
  ### Patch Changes
@@ -12,6 +12,14 @@ import type { UpsertVectorArgs } from '@mastra/core/vector';
12
12
  import type { UpsertVectorParams } from '@mastra/core/vector';
13
13
  import type { VectorFilter } from '@mastra/core/vector/filter';
14
14
 
15
+ /**
16
+ * Vector store specific prompt that details supported operators and examples.
17
+ * This prompt helps users construct valid filters for MongoDB Vector.
18
+ */
19
+ declare const MONGODB_PROMPT = "When querying MongoDB Vector, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n- $all: Match all values in array\n Example: { \"tags\": { \"$all\": [\"premium\", \"sale\"] } }\n- $elemMatch: Match array elements that meet all specified conditions\n Example: { \"items\": { \"$elemMatch\": { \"price\": { \"$gt\": 100 } } } }\n- $size: Match arrays with specific length\n Example: { \"tags\": { \"$size\": 3 } }\n\nLogical Operators:\n- $and: Logical AND (can be implicit or explicit)\n Implicit Example: { \"price\": { \"$gt\": 100 }, \"category\": \"electronics\" }\n Explicit Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n- $not: Logical NOT\n Example: { \"$not\": { \"category\": \"electronics\" } }\n- $nor: Logical NOR\n Example: { \"$nor\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n- $type: Check field type\n Example: { \"price\": { \"$type\": \"number\" } }\n\nText Search Operators:\n- $text: Full text search\n Example: { \"$text\": { \"$search\": \"gaming laptop\" } }\n- $regex: Regular expression match\n Example: { \"name\": { \"$regex\": \"^Gaming\" } }\n\nRestrictions:\n- Only logical operators ($and, $or, $not, $nor) can be used at the top level\n- Empty arrays in array operators will return no results\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported\n- At least one key-value pair is required in filter object\n- Empty objects and undefined values are treated as no filter\n- Invalid types in comparison operators will throw errors\n- All non-logical operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- Logical operators ($and, $or, $not, $nor):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"tags\": { \"$all\": [\"premium\", \"sale\"] } },\n { \"items\": { \"$elemMatch\": { \"price\": { \"$gt\": 50 }, \"inStock\": true } } },\n { \"$text\": { \"$search\": \"gaming laptop\" } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": true }\n ]},\n { \"$not\": { \"status\": \"discontinued\" } }\n ]\n}";
20
+ export { MONGODB_PROMPT }
21
+ export { MONGODB_PROMPT as MONGODB_PROMPT_alias_1 }
22
+
15
23
  /**
16
24
  * Translator for MongoDB filter queries.
17
25
  * Maintains MongoDB-compatible syntax while ensuring proper validation
@@ -12,6 +12,14 @@ import type { UpsertVectorArgs } from '@mastra/core/vector';
12
12
  import type { UpsertVectorParams } from '@mastra/core/vector';
13
13
  import type { VectorFilter } from '@mastra/core/vector/filter';
14
14
 
15
+ /**
16
+ * Vector store specific prompt that details supported operators and examples.
17
+ * This prompt helps users construct valid filters for MongoDB Vector.
18
+ */
19
+ declare const MONGODB_PROMPT = "When querying MongoDB Vector, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n- $all: Match all values in array\n Example: { \"tags\": { \"$all\": [\"premium\", \"sale\"] } }\n- $elemMatch: Match array elements that meet all specified conditions\n Example: { \"items\": { \"$elemMatch\": { \"price\": { \"$gt\": 100 } } } }\n- $size: Match arrays with specific length\n Example: { \"tags\": { \"$size\": 3 } }\n\nLogical Operators:\n- $and: Logical AND (can be implicit or explicit)\n Implicit Example: { \"price\": { \"$gt\": 100 }, \"category\": \"electronics\" }\n Explicit Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n- $not: Logical NOT\n Example: { \"$not\": { \"category\": \"electronics\" } }\n- $nor: Logical NOR\n Example: { \"$nor\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n- $type: Check field type\n Example: { \"price\": { \"$type\": \"number\" } }\n\nText Search Operators:\n- $text: Full text search\n Example: { \"$text\": { \"$search\": \"gaming laptop\" } }\n- $regex: Regular expression match\n Example: { \"name\": { \"$regex\": \"^Gaming\" } }\n\nRestrictions:\n- Only logical operators ($and, $or, $not, $nor) can be used at the top level\n- Empty arrays in array operators will return no results\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported\n- At least one key-value pair is required in filter object\n- Empty objects and undefined values are treated as no filter\n- Invalid types in comparison operators will throw errors\n- All non-logical operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- Logical operators ($and, $or, $not, $nor):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"tags\": { \"$all\": [\"premium\", \"sale\"] } },\n { \"items\": { \"$elemMatch\": { \"price\": { \"$gt\": 50 }, \"inStock\": true } } },\n { \"$text\": { \"$search\": \"gaming laptop\" } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": true }\n ]},\n { \"$not\": { \"status\": \"discontinued\" } }\n ]\n}";
20
+ export { MONGODB_PROMPT }
21
+ export { MONGODB_PROMPT as MONGODB_PROMPT_alias_1 }
22
+
15
23
  /**
16
24
  * Translator for MongoDB filter queries.
17
25
  * Maintains MongoDB-compatible syntax while ensuring proper validation
package/dist/index.cjs CHANGED
@@ -358,4 +358,100 @@ var MongoDBVector = class extends vector.MastraVector {
358
358
  }
359
359
  };
360
360
 
361
+ // src/vector/prompt.ts
362
+ var MONGODB_PROMPT = `When querying MongoDB Vector, you can ONLY use the operators listed below. Any other operators will be rejected.
363
+ Important: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.
364
+ If a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.
365
+
366
+ Basic Comparison Operators:
367
+ - $eq: Exact match (default when using field: value)
368
+ Example: { "category": "electronics" }
369
+ - $ne: Not equal
370
+ Example: { "category": { "$ne": "electronics" } }
371
+ - $gt: Greater than
372
+ Example: { "price": { "$gt": 100 } }
373
+ - $gte: Greater than or equal
374
+ Example: { "price": { "$gte": 100 } }
375
+ - $lt: Less than
376
+ Example: { "price": { "$lt": 100 } }
377
+ - $lte: Less than or equal
378
+ Example: { "price": { "$lte": 100 } }
379
+
380
+ Array Operators:
381
+ - $in: Match any value in array
382
+ Example: { "category": { "$in": ["electronics", "books"] } }
383
+ - $nin: Does not match any value in array
384
+ Example: { "category": { "$nin": ["electronics", "books"] } }
385
+ - $all: Match all values in array
386
+ Example: { "tags": { "$all": ["premium", "sale"] } }
387
+ - $elemMatch: Match array elements that meet all specified conditions
388
+ Example: { "items": { "$elemMatch": { "price": { "$gt": 100 } } } }
389
+ - $size: Match arrays with specific length
390
+ Example: { "tags": { "$size": 3 } }
391
+
392
+ Logical Operators:
393
+ - $and: Logical AND (can be implicit or explicit)
394
+ Implicit Example: { "price": { "$gt": 100 }, "category": "electronics" }
395
+ Explicit Example: { "$and": [{ "price": { "$gt": 100 } }, { "category": "electronics" }] }
396
+ - $or: Logical OR
397
+ Example: { "$or": [{ "price": { "$lt": 50 } }, { "category": "books" }] }
398
+ - $not: Logical NOT
399
+ Example: { "$not": { "category": "electronics" } }
400
+ - $nor: Logical NOR
401
+ Example: { "$nor": [{ "price": { "$lt": 50 } }, { "category": "books" }] }
402
+
403
+ Element Operators:
404
+ - $exists: Check if field exists
405
+ Example: { "rating": { "$exists": true } }
406
+ - $type: Check field type
407
+ Example: { "price": { "$type": "number" } }
408
+
409
+ Text Search Operators:
410
+ - $text: Full text search
411
+ Example: { "$text": { "$search": "gaming laptop" } }
412
+ - $regex: Regular expression match
413
+ Example: { "name": { "$regex": "^Gaming" } }
414
+
415
+ Restrictions:
416
+ - Only logical operators ($and, $or, $not, $nor) can be used at the top level
417
+ - Empty arrays in array operators will return no results
418
+ - Nested fields are supported using dot notation
419
+ - Multiple conditions on the same field are supported
420
+ - At least one key-value pair is required in filter object
421
+ - Empty objects and undefined values are treated as no filter
422
+ - Invalid types in comparison operators will throw errors
423
+ - All non-logical operators must be used within a field condition
424
+ Valid: { "field": { "$gt": 100 } }
425
+ Valid: { "$and": [...] }
426
+ Invalid: { "$gt": 100 }
427
+ - Logical operators must contain field conditions, not direct operators
428
+ Valid: { "$and": [{ "field": { "$gt": 100 } }] }
429
+ Invalid: { "$and": [{ "$gt": 100 }] }
430
+ - Logical operators ($and, $or, $not, $nor):
431
+ - Can only be used at top level or nested within other logical operators
432
+ - Can not be used on a field level, or be nested inside a field
433
+ - Can not be used inside an operator
434
+ - Valid: { "$and": [{ "field": { "$gt": 100 } }] }
435
+ - Valid: { "$or": [{ "$and": [{ "field": { "$gt": 100 } }] }] }
436
+ - Invalid: { "field": { "$and": [{ "$gt": 100 }] } }
437
+ - Invalid: { "field": { "$or": [{ "$gt": 100 }] } }
438
+ - Invalid: { "field": { "$gt": { "$and": [{...}] } } }
439
+
440
+ Example Complex Query:
441
+ {
442
+ "$and": [
443
+ { "category": { "$in": ["electronics", "computers"] } },
444
+ { "price": { "$gte": 100, "$lte": 1000 } },
445
+ { "tags": { "$all": ["premium", "sale"] } },
446
+ { "items": { "$elemMatch": { "price": { "$gt": 50 }, "inStock": true } } },
447
+ { "$text": { "$search": "gaming laptop" } },
448
+ { "$or": [
449
+ { "stock": { "$gt": 0 } },
450
+ { "preorder": true }
451
+ ]},
452
+ { "$not": { "status": "discontinued" } }
453
+ ]
454
+ }`;
455
+
456
+ exports.MONGODB_PROMPT = MONGODB_PROMPT;
361
457
  exports.MongoDBVector = MongoDBVector;
package/dist/index.d.cts CHANGED
@@ -1,3 +1,4 @@
1
+ export { MONGODB_PROMPT } from './_tsup-dts-rollup.cjs';
1
2
  export { MongoDBUpsertArgs } from './_tsup-dts-rollup.cjs';
2
3
  export { MongoDBQueryArgs } from './_tsup-dts-rollup.cjs';
3
4
  export { MongoDBUpsertParams } from './_tsup-dts-rollup.cjs';
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export { MONGODB_PROMPT } from './_tsup-dts-rollup.js';
1
2
  export { MongoDBUpsertArgs } from './_tsup-dts-rollup.js';
2
3
  export { MongoDBQueryArgs } from './_tsup-dts-rollup.js';
3
4
  export { MongoDBUpsertParams } from './_tsup-dts-rollup.js';
package/dist/index.js CHANGED
@@ -356,4 +356,99 @@ var MongoDBVector = class extends MastraVector {
356
356
  }
357
357
  };
358
358
 
359
- export { MongoDBVector };
359
+ // src/vector/prompt.ts
360
+ var MONGODB_PROMPT = `When querying MongoDB Vector, you can ONLY use the operators listed below. Any other operators will be rejected.
361
+ Important: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.
362
+ If a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.
363
+
364
+ Basic Comparison Operators:
365
+ - $eq: Exact match (default when using field: value)
366
+ Example: { "category": "electronics" }
367
+ - $ne: Not equal
368
+ Example: { "category": { "$ne": "electronics" } }
369
+ - $gt: Greater than
370
+ Example: { "price": { "$gt": 100 } }
371
+ - $gte: Greater than or equal
372
+ Example: { "price": { "$gte": 100 } }
373
+ - $lt: Less than
374
+ Example: { "price": { "$lt": 100 } }
375
+ - $lte: Less than or equal
376
+ Example: { "price": { "$lte": 100 } }
377
+
378
+ Array Operators:
379
+ - $in: Match any value in array
380
+ Example: { "category": { "$in": ["electronics", "books"] } }
381
+ - $nin: Does not match any value in array
382
+ Example: { "category": { "$nin": ["electronics", "books"] } }
383
+ - $all: Match all values in array
384
+ Example: { "tags": { "$all": ["premium", "sale"] } }
385
+ - $elemMatch: Match array elements that meet all specified conditions
386
+ Example: { "items": { "$elemMatch": { "price": { "$gt": 100 } } } }
387
+ - $size: Match arrays with specific length
388
+ Example: { "tags": { "$size": 3 } }
389
+
390
+ Logical Operators:
391
+ - $and: Logical AND (can be implicit or explicit)
392
+ Implicit Example: { "price": { "$gt": 100 }, "category": "electronics" }
393
+ Explicit Example: { "$and": [{ "price": { "$gt": 100 } }, { "category": "electronics" }] }
394
+ - $or: Logical OR
395
+ Example: { "$or": [{ "price": { "$lt": 50 } }, { "category": "books" }] }
396
+ - $not: Logical NOT
397
+ Example: { "$not": { "category": "electronics" } }
398
+ - $nor: Logical NOR
399
+ Example: { "$nor": [{ "price": { "$lt": 50 } }, { "category": "books" }] }
400
+
401
+ Element Operators:
402
+ - $exists: Check if field exists
403
+ Example: { "rating": { "$exists": true } }
404
+ - $type: Check field type
405
+ Example: { "price": { "$type": "number" } }
406
+
407
+ Text Search Operators:
408
+ - $text: Full text search
409
+ Example: { "$text": { "$search": "gaming laptop" } }
410
+ - $regex: Regular expression match
411
+ Example: { "name": { "$regex": "^Gaming" } }
412
+
413
+ Restrictions:
414
+ - Only logical operators ($and, $or, $not, $nor) can be used at the top level
415
+ - Empty arrays in array operators will return no results
416
+ - Nested fields are supported using dot notation
417
+ - Multiple conditions on the same field are supported
418
+ - At least one key-value pair is required in filter object
419
+ - Empty objects and undefined values are treated as no filter
420
+ - Invalid types in comparison operators will throw errors
421
+ - All non-logical operators must be used within a field condition
422
+ Valid: { "field": { "$gt": 100 } }
423
+ Valid: { "$and": [...] }
424
+ Invalid: { "$gt": 100 }
425
+ - Logical operators must contain field conditions, not direct operators
426
+ Valid: { "$and": [{ "field": { "$gt": 100 } }] }
427
+ Invalid: { "$and": [{ "$gt": 100 }] }
428
+ - Logical operators ($and, $or, $not, $nor):
429
+ - Can only be used at top level or nested within other logical operators
430
+ - Can not be used on a field level, or be nested inside a field
431
+ - Can not be used inside an operator
432
+ - Valid: { "$and": [{ "field": { "$gt": 100 } }] }
433
+ - Valid: { "$or": [{ "$and": [{ "field": { "$gt": 100 } }] }] }
434
+ - Invalid: { "field": { "$and": [{ "$gt": 100 }] } }
435
+ - Invalid: { "field": { "$or": [{ "$gt": 100 }] } }
436
+ - Invalid: { "field": { "$gt": { "$and": [{...}] } } }
437
+
438
+ Example Complex Query:
439
+ {
440
+ "$and": [
441
+ { "category": { "$in": ["electronics", "computers"] } },
442
+ { "price": { "$gte": 100, "$lte": 1000 } },
443
+ { "tags": { "$all": ["premium", "sale"] } },
444
+ { "items": { "$elemMatch": { "price": { "$gt": 50 }, "inStock": true } } },
445
+ { "$text": { "$search": "gaming laptop" } },
446
+ { "$or": [
447
+ { "stock": { "$gt": 0 } },
448
+ { "preorder": true }
449
+ ]},
450
+ { "$not": { "status": "discontinued" } }
451
+ ]
452
+ }`;
453
+
454
+ export { MONGODB_PROMPT, MongoDBVector };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/mongodb",
3
- "version": "0.0.2-alpha.2",
3
+ "version": "0.0.2-alpha.4",
4
4
  "description": "MongoDB provider for Mastra - includes vector store capabilities",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -23,15 +23,15 @@
23
23
  "cloudflare": "^4.1.0",
24
24
  "mongodb": "^6.15.0",
25
25
  "uuid": "^11.1.0",
26
- "@mastra/core": "^0.9.1-alpha.3"
26
+ "@mastra/core": "^0.9.1-alpha.5"
27
27
  },
28
28
  "devDependencies": {
29
- "@microsoft/api-extractor": "^7.52.1",
29
+ "@microsoft/api-extractor": "^7.52.5",
30
30
  "@types/node": "^20.17.27",
31
31
  "eslint": "^9.23.0",
32
32
  "tsup": "^8.4.0",
33
33
  "typescript": "^5.8.2",
34
- "vitest": "^3.0.9",
34
+ "vitest": "^3.1.2",
35
35
  "@internal/lint": "0.0.2"
36
36
  },
37
37
  "scripts": {
package/src/index.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from './vector';
2
+ export { MONGODB_PROMPT } from './vector/prompt';
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Vector store specific prompt that details supported operators and examples.
3
+ * This prompt helps users construct valid filters for MongoDB Vector.
4
+ */
5
+ export const MONGODB_PROMPT = `When querying MongoDB Vector, you can ONLY use the operators listed below. Any other operators will be rejected.
6
+ Important: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.
7
+ If a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.
8
+
9
+ Basic Comparison Operators:
10
+ - $eq: Exact match (default when using field: value)
11
+ Example: { "category": "electronics" }
12
+ - $ne: Not equal
13
+ Example: { "category": { "$ne": "electronics" } }
14
+ - $gt: Greater than
15
+ Example: { "price": { "$gt": 100 } }
16
+ - $gte: Greater than or equal
17
+ Example: { "price": { "$gte": 100 } }
18
+ - $lt: Less than
19
+ Example: { "price": { "$lt": 100 } }
20
+ - $lte: Less than or equal
21
+ Example: { "price": { "$lte": 100 } }
22
+
23
+ Array Operators:
24
+ - $in: Match any value in array
25
+ Example: { "category": { "$in": ["electronics", "books"] } }
26
+ - $nin: Does not match any value in array
27
+ Example: { "category": { "$nin": ["electronics", "books"] } }
28
+ - $all: Match all values in array
29
+ Example: { "tags": { "$all": ["premium", "sale"] } }
30
+ - $elemMatch: Match array elements that meet all specified conditions
31
+ Example: { "items": { "$elemMatch": { "price": { "$gt": 100 } } } }
32
+ - $size: Match arrays with specific length
33
+ Example: { "tags": { "$size": 3 } }
34
+
35
+ Logical Operators:
36
+ - $and: Logical AND (can be implicit or explicit)
37
+ Implicit Example: { "price": { "$gt": 100 }, "category": "electronics" }
38
+ Explicit Example: { "$and": [{ "price": { "$gt": 100 } }, { "category": "electronics" }] }
39
+ - $or: Logical OR
40
+ Example: { "$or": [{ "price": { "$lt": 50 } }, { "category": "books" }] }
41
+ - $not: Logical NOT
42
+ Example: { "$not": { "category": "electronics" } }
43
+ - $nor: Logical NOR
44
+ Example: { "$nor": [{ "price": { "$lt": 50 } }, { "category": "books" }] }
45
+
46
+ Element Operators:
47
+ - $exists: Check if field exists
48
+ Example: { "rating": { "$exists": true } }
49
+ - $type: Check field type
50
+ Example: { "price": { "$type": "number" } }
51
+
52
+ Text Search Operators:
53
+ - $text: Full text search
54
+ Example: { "$text": { "$search": "gaming laptop" } }
55
+ - $regex: Regular expression match
56
+ Example: { "name": { "$regex": "^Gaming" } }
57
+
58
+ Restrictions:
59
+ - Only logical operators ($and, $or, $not, $nor) can be used at the top level
60
+ - Empty arrays in array operators will return no results
61
+ - Nested fields are supported using dot notation
62
+ - Multiple conditions on the same field are supported
63
+ - At least one key-value pair is required in filter object
64
+ - Empty objects and undefined values are treated as no filter
65
+ - Invalid types in comparison operators will throw errors
66
+ - All non-logical operators must be used within a field condition
67
+ Valid: { "field": { "$gt": 100 } }
68
+ Valid: { "$and": [...] }
69
+ Invalid: { "$gt": 100 }
70
+ - Logical operators must contain field conditions, not direct operators
71
+ Valid: { "$and": [{ "field": { "$gt": 100 } }] }
72
+ Invalid: { "$and": [{ "$gt": 100 }] }
73
+ - Logical operators ($and, $or, $not, $nor):
74
+ - Can only be used at top level or nested within other logical operators
75
+ - Can not be used on a field level, or be nested inside a field
76
+ - Can not be used inside an operator
77
+ - Valid: { "$and": [{ "field": { "$gt": 100 } }] }
78
+ - Valid: { "$or": [{ "$and": [{ "field": { "$gt": 100 } }] }] }
79
+ - Invalid: { "field": { "$and": [{ "$gt": 100 }] } }
80
+ - Invalid: { "field": { "$or": [{ "$gt": 100 }] } }
81
+ - Invalid: { "field": { "$gt": { "$and": [{...}] } } }
82
+
83
+ Example Complex Query:
84
+ {
85
+ "$and": [
86
+ { "category": { "$in": ["electronics", "computers"] } },
87
+ { "price": { "$gte": 100, "$lte": 1000 } },
88
+ { "tags": { "$all": ["premium", "sale"] } },
89
+ { "items": { "$elemMatch": { "price": { "$gt": 50 }, "inStock": true } } },
90
+ { "$text": { "$search": "gaming laptop" } },
91
+ { "$or": [
92
+ { "stock": { "$gt": 0 } },
93
+ { "preorder": true }
94
+ ]},
95
+ { "$not": { "status": "discontinued" } }
96
+ ]
97
+ }`;