@mastra/pinecone 0.2.10-alpha.3 → 0.2.10-alpha.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.
@@ -1,23 +1,23 @@
1
1
 
2
- > @mastra/pinecone@0.2.10-alpha.3 build /home/runner/work/mastra/mastra/stores/pinecone
2
+ > @mastra/pinecone@0.2.10-alpha.5 build /home/runner/work/mastra/mastra/stores/pinecone
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 5807ms
9
+ TSC ⚡️ Build success in 5190ms
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/pinecone/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/pinecone/dist/_tsup-dts-rollup.d.cts
16
- DTS ⚡️ Build success in 9050ms
16
+ DTS ⚡️ Build success in 8899ms
17
17
  CLI Cleaning output folder
18
18
  ESM Build start
19
19
  CJS Build start
20
- ESM dist/index.js 7.09 KB
21
- ESM ⚡️ Build success in 683ms
22
- CJS dist/index.cjs 7.13 KB
23
- CJS ⚡️ Build success in 684ms
20
+ CJS dist/index.cjs 10.41 KB
21
+ CJS ⚡️ Build success in 486ms
22
+ ESM dist/index.js 10.35 KB
23
+ ESM ⚡️ Build success in 627ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @mastra/pinecone
2
2
 
3
+ ## 0.2.10-alpha.5
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.2.10-alpha.4
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.2.10-alpha.3
4
20
 
5
21
  ### Patch Changes
@@ -13,6 +13,14 @@ import type { UpsertVectorArgs } from '@mastra/core/vector';
13
13
  import type { UpsertVectorParams } from '@mastra/core/vector';
14
14
  import type { VectorFilter } from '@mastra/core/vector/filter';
15
15
 
16
+ /**
17
+ * Vector store specific prompt that details supported operators and examples.
18
+ * This prompt helps users construct valid filters for Pinecone Vector.
19
+ */
20
+ declare const PINECONE_PROMPT = "When querying Pinecone, 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\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\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n\nRestrictions:\n- Regex patterns are not supported\n- Only $and and $or logical operators are supported at the top level\n- Empty arrays in $in/$nin will return no results\n- A non-empty array is required for $all operator\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\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):\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 { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": true }\n ]}\n ]\n}";
21
+ export { PINECONE_PROMPT }
22
+ export { PINECONE_PROMPT as PINECONE_PROMPT_alias_1 }
23
+
16
24
  export declare class PineconeFilterTranslator extends BaseFilterTranslator {
17
25
  protected getSupportedOperators(): OperatorSupport;
18
26
  translate(filter?: VectorFilter): VectorFilter;
@@ -13,6 +13,14 @@ import type { UpsertVectorArgs } from '@mastra/core/vector';
13
13
  import type { UpsertVectorParams } from '@mastra/core/vector';
14
14
  import type { VectorFilter } from '@mastra/core/vector/filter';
15
15
 
16
+ /**
17
+ * Vector store specific prompt that details supported operators and examples.
18
+ * This prompt helps users construct valid filters for Pinecone Vector.
19
+ */
20
+ declare const PINECONE_PROMPT = "When querying Pinecone, 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\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\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n\nRestrictions:\n- Regex patterns are not supported\n- Only $and and $or logical operators are supported at the top level\n- Empty arrays in $in/$nin will return no results\n- A non-empty array is required for $all operator\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\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):\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 { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": true }\n ]}\n ]\n}";
21
+ export { PINECONE_PROMPT }
22
+ export { PINECONE_PROMPT as PINECONE_PROMPT_alias_1 }
23
+
16
24
  export declare class PineconeFilterTranslator extends BaseFilterTranslator {
17
25
  protected getSupportedOperators(): OperatorSupport;
18
26
  translate(filter?: VectorFilter): VectorFilter;
package/dist/index.cjs CHANGED
@@ -211,4 +211,84 @@ var PineconeVector = class extends vector.MastraVector {
211
211
  }
212
212
  };
213
213
 
214
+ // src/vector/prompt.ts
215
+ var PINECONE_PROMPT = `When querying Pinecone, you can ONLY use the operators listed below. Any other operators will be rejected.
216
+ Important: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.
217
+ 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.
218
+
219
+ Basic Comparison Operators:
220
+ - $eq: Exact match (default when using field: value)
221
+ Example: { "category": "electronics" }
222
+ - $ne: Not equal
223
+ Example: { "category": { "$ne": "electronics" } }
224
+ - $gt: Greater than
225
+ Example: { "price": { "$gt": 100 } }
226
+ - $gte: Greater than or equal
227
+ Example: { "price": { "$gte": 100 } }
228
+ - $lt: Less than
229
+ Example: { "price": { "$lt": 100 } }
230
+ - $lte: Less than or equal
231
+ Example: { "price": { "$lte": 100 } }
232
+
233
+ Array Operators:
234
+ - $in: Match any value in array
235
+ Example: { "category": { "$in": ["electronics", "books"] } }
236
+ - $nin: Does not match any value in array
237
+ Example: { "category": { "$nin": ["electronics", "books"] } }
238
+ - $all: Match all values in array
239
+ Example: { "tags": { "$all": ["premium", "sale"] } }
240
+
241
+ Logical Operators:
242
+ - $and: Logical AND (can be implicit or explicit)
243
+ Implicit Example: { "price": { "$gt": 100 }, "category": "electronics" }
244
+ Explicit Example: { "$and": [{ "price": { "$gt": 100 } }, { "category": "electronics" }] }
245
+ - $or: Logical OR
246
+ Example: { "$or": [{ "price": { "$lt": 50 } }, { "category": "books" }] }
247
+
248
+ Element Operators:
249
+ - $exists: Check if field exists
250
+ Example: { "rating": { "$exists": true } }
251
+
252
+ Restrictions:
253
+ - Regex patterns are not supported
254
+ - Only $and and $or logical operators are supported at the top level
255
+ - Empty arrays in $in/$nin will return no results
256
+ - A non-empty array is required for $all operator
257
+ - Nested fields are supported using dot notation
258
+ - Multiple conditions on the same field are supported with both implicit and explicit $and
259
+ - At least one key-value pair is required in filter object
260
+ - Empty objects and undefined values are treated as no filter
261
+ - Invalid types in comparison operators will throw errors
262
+ - All non-logical operators must be used within a field condition
263
+ Valid: { "field": { "$gt": 100 } }
264
+ Valid: { "$and": [...] }
265
+ Invalid: { "$gt": 100 }
266
+ - Logical operators must contain field conditions, not direct operators
267
+ Valid: { "$and": [{ "field": { "$gt": 100 } }] }
268
+ Invalid: { "$and": [{ "$gt": 100 }] }
269
+ - Logical operators ($and, $or):
270
+ - Can only be used at top level or nested within other logical operators
271
+ - Can not be used on a field level, or be nested inside a field
272
+ - Can not be used inside an operator
273
+ - Valid: { "$and": [{ "field": { "$gt": 100 } }] }
274
+ - Valid: { "$or": [{ "$and": [{ "field": { "$gt": 100 } }] }] }
275
+ - Invalid: { "field": { "$and": [{ "$gt": 100 }] } }
276
+ - Invalid: { "field": { "$or": [{ "$gt": 100 }] } }
277
+ - Invalid: { "field": { "$gt": { "$and": [{...}] } } }
278
+
279
+ Example Complex Query:
280
+ {
281
+ "$and": [
282
+ { "category": { "$in": ["electronics", "computers"] } },
283
+ { "price": { "$gte": 100, "$lte": 1000 } },
284
+ { "tags": { "$all": ["premium", "sale"] } },
285
+ { "rating": { "$exists": true, "$gt": 4 } },
286
+ { "$or": [
287
+ { "stock": { "$gt": 0 } },
288
+ { "preorder": true }
289
+ ]}
290
+ ]
291
+ }`;
292
+
293
+ exports.PINECONE_PROMPT = PINECONE_PROMPT;
214
294
  exports.PineconeVector = PineconeVector;
package/dist/index.d.cts CHANGED
@@ -1 +1,2 @@
1
+ export { PINECONE_PROMPT } from './_tsup-dts-rollup.cjs';
1
2
  export { PineconeVector } from './_tsup-dts-rollup.cjs';
package/dist/index.d.ts CHANGED
@@ -1 +1,2 @@
1
+ export { PINECONE_PROMPT } from './_tsup-dts-rollup.js';
1
2
  export { PineconeVector } from './_tsup-dts-rollup.js';
package/dist/index.js CHANGED
@@ -209,4 +209,83 @@ var PineconeVector = class extends MastraVector {
209
209
  }
210
210
  };
211
211
 
212
- export { PineconeVector };
212
+ // src/vector/prompt.ts
213
+ var PINECONE_PROMPT = `When querying Pinecone, you can ONLY use the operators listed below. Any other operators will be rejected.
214
+ Important: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.
215
+ 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.
216
+
217
+ Basic Comparison Operators:
218
+ - $eq: Exact match (default when using field: value)
219
+ Example: { "category": "electronics" }
220
+ - $ne: Not equal
221
+ Example: { "category": { "$ne": "electronics" } }
222
+ - $gt: Greater than
223
+ Example: { "price": { "$gt": 100 } }
224
+ - $gte: Greater than or equal
225
+ Example: { "price": { "$gte": 100 } }
226
+ - $lt: Less than
227
+ Example: { "price": { "$lt": 100 } }
228
+ - $lte: Less than or equal
229
+ Example: { "price": { "$lte": 100 } }
230
+
231
+ Array Operators:
232
+ - $in: Match any value in array
233
+ Example: { "category": { "$in": ["electronics", "books"] } }
234
+ - $nin: Does not match any value in array
235
+ Example: { "category": { "$nin": ["electronics", "books"] } }
236
+ - $all: Match all values in array
237
+ Example: { "tags": { "$all": ["premium", "sale"] } }
238
+
239
+ Logical Operators:
240
+ - $and: Logical AND (can be implicit or explicit)
241
+ Implicit Example: { "price": { "$gt": 100 }, "category": "electronics" }
242
+ Explicit Example: { "$and": [{ "price": { "$gt": 100 } }, { "category": "electronics" }] }
243
+ - $or: Logical OR
244
+ Example: { "$or": [{ "price": { "$lt": 50 } }, { "category": "books" }] }
245
+
246
+ Element Operators:
247
+ - $exists: Check if field exists
248
+ Example: { "rating": { "$exists": true } }
249
+
250
+ Restrictions:
251
+ - Regex patterns are not supported
252
+ - Only $and and $or logical operators are supported at the top level
253
+ - Empty arrays in $in/$nin will return no results
254
+ - A non-empty array is required for $all operator
255
+ - Nested fields are supported using dot notation
256
+ - Multiple conditions on the same field are supported with both implicit and explicit $and
257
+ - At least one key-value pair is required in filter object
258
+ - Empty objects and undefined values are treated as no filter
259
+ - Invalid types in comparison operators will throw errors
260
+ - All non-logical operators must be used within a field condition
261
+ Valid: { "field": { "$gt": 100 } }
262
+ Valid: { "$and": [...] }
263
+ Invalid: { "$gt": 100 }
264
+ - Logical operators must contain field conditions, not direct operators
265
+ Valid: { "$and": [{ "field": { "$gt": 100 } }] }
266
+ Invalid: { "$and": [{ "$gt": 100 }] }
267
+ - Logical operators ($and, $or):
268
+ - Can only be used at top level or nested within other logical operators
269
+ - Can not be used on a field level, or be nested inside a field
270
+ - Can not be used inside an operator
271
+ - Valid: { "$and": [{ "field": { "$gt": 100 } }] }
272
+ - Valid: { "$or": [{ "$and": [{ "field": { "$gt": 100 } }] }] }
273
+ - Invalid: { "field": { "$and": [{ "$gt": 100 }] } }
274
+ - Invalid: { "field": { "$or": [{ "$gt": 100 }] } }
275
+ - Invalid: { "field": { "$gt": { "$and": [{...}] } } }
276
+
277
+ Example Complex Query:
278
+ {
279
+ "$and": [
280
+ { "category": { "$in": ["electronics", "computers"] } },
281
+ { "price": { "$gte": 100, "$lte": 1000 } },
282
+ { "tags": { "$all": ["premium", "sale"] } },
283
+ { "rating": { "$exists": true, "$gt": 4 } },
284
+ { "$or": [
285
+ { "stock": { "$gt": 0 } },
286
+ { "preorder": true }
287
+ ]}
288
+ ]
289
+ }`;
290
+
291
+ export { PINECONE_PROMPT, PineconeVector };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/pinecone",
3
- "version": "0.2.10-alpha.3",
3
+ "version": "0.2.10-alpha.5",
4
4
  "description": "Pinecone vector store provider for Mastra",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -21,16 +21,16 @@
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
23
  "@pinecone-database/pinecone": "^3.0.3",
24
- "@mastra/core": "^0.9.1-alpha.3"
24
+ "@mastra/core": "^0.9.1-alpha.5"
25
25
  },
26
26
  "devDependencies": {
27
- "@microsoft/api-extractor": "^7.52.1",
27
+ "@microsoft/api-extractor": "^7.52.5",
28
28
  "@types/node": "^20.17.27",
29
29
  "dotenv": "^16.4.7",
30
30
  "eslint": "^9.23.0",
31
31
  "tsup": "^8.4.0",
32
32
  "typescript": "^5.8.2",
33
- "vitest": "^3.0.9",
33
+ "vitest": "^3.1.2",
34
34
  "@internal/lint": "0.0.2"
35
35
  },
36
36
  "scripts": {
package/src/index.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from './vector/index';
2
+ export { PINECONE_PROMPT } from './vector/prompt';
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Vector store specific prompt that details supported operators and examples.
3
+ * This prompt helps users construct valid filters for Pinecone Vector.
4
+ */
5
+ export const PINECONE_PROMPT = `When querying Pinecone, 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
+
31
+ Logical Operators:
32
+ - $and: Logical AND (can be implicit or explicit)
33
+ Implicit Example: { "price": { "$gt": 100 }, "category": "electronics" }
34
+ Explicit Example: { "$and": [{ "price": { "$gt": 100 } }, { "category": "electronics" }] }
35
+ - $or: Logical OR
36
+ Example: { "$or": [{ "price": { "$lt": 50 } }, { "category": "books" }] }
37
+
38
+ Element Operators:
39
+ - $exists: Check if field exists
40
+ Example: { "rating": { "$exists": true } }
41
+
42
+ Restrictions:
43
+ - Regex patterns are not supported
44
+ - Only $and and $or logical operators are supported at the top level
45
+ - Empty arrays in $in/$nin will return no results
46
+ - A non-empty array is required for $all operator
47
+ - Nested fields are supported using dot notation
48
+ - Multiple conditions on the same field are supported with both implicit and explicit $and
49
+ - At least one key-value pair is required in filter object
50
+ - Empty objects and undefined values are treated as no filter
51
+ - Invalid types in comparison operators will throw errors
52
+ - All non-logical operators must be used within a field condition
53
+ Valid: { "field": { "$gt": 100 } }
54
+ Valid: { "$and": [...] }
55
+ Invalid: { "$gt": 100 }
56
+ - Logical operators must contain field conditions, not direct operators
57
+ Valid: { "$and": [{ "field": { "$gt": 100 } }] }
58
+ Invalid: { "$and": [{ "$gt": 100 }] }
59
+ - Logical operators ($and, $or):
60
+ - Can only be used at top level or nested within other logical operators
61
+ - Can not be used on a field level, or be nested inside a field
62
+ - Can not be used inside an operator
63
+ - Valid: { "$and": [{ "field": { "$gt": 100 } }] }
64
+ - Valid: { "$or": [{ "$and": [{ "field": { "$gt": 100 } }] }] }
65
+ - Invalid: { "field": { "$and": [{ "$gt": 100 }] } }
66
+ - Invalid: { "field": { "$or": [{ "$gt": 100 }] } }
67
+ - Invalid: { "field": { "$gt": { "$and": [{...}] } } }
68
+
69
+ Example Complex Query:
70
+ {
71
+ "$and": [
72
+ { "category": { "$in": ["electronics", "computers"] } },
73
+ { "price": { "$gte": 100, "$lte": 1000 } },
74
+ { "tags": { "$all": ["premium", "sale"] } },
75
+ { "rating": { "$exists": true, "$gt": 4 } },
76
+ { "$or": [
77
+ { "stock": { "$gt": 0 } },
78
+ { "preorder": true }
79
+ ]}
80
+ ]
81
+ }`;