@documentdb-js/operator-registry 0.8.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.
Files changed (79) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +92 -0
  3. package/dist/accumulators.d.ts +2 -0
  4. package/dist/accumulators.d.ts.map +1 -0
  5. package/dist/accumulators.js +177 -0
  6. package/dist/accumulators.js.map +1 -0
  7. package/dist/bsonConstructors.d.ts +2 -0
  8. package/dist/bsonConstructors.d.ts.map +1 -0
  9. package/dist/bsonConstructors.js +81 -0
  10. package/dist/bsonConstructors.js.map +1 -0
  11. package/dist/docLinks.d.ts +13 -0
  12. package/dist/docLinks.d.ts.map +1 -0
  13. package/dist/docLinks.js +76 -0
  14. package/dist/docLinks.js.map +1 -0
  15. package/dist/docLinks.test.d.ts +2 -0
  16. package/dist/docLinks.test.d.ts.map +1 -0
  17. package/dist/docLinks.test.js +67 -0
  18. package/dist/docLinks.test.js.map +1 -0
  19. package/dist/expressionOperators.d.ts +2 -0
  20. package/dist/expressionOperators.d.ts.map +1 -0
  21. package/dist/expressionOperators.js +1094 -0
  22. package/dist/expressionOperators.js.map +1 -0
  23. package/dist/getFilteredCompletions.d.ts +48 -0
  24. package/dist/getFilteredCompletions.d.ts.map +1 -0
  25. package/dist/getFilteredCompletions.js +90 -0
  26. package/dist/getFilteredCompletions.js.map +1 -0
  27. package/dist/getFilteredCompletions.test.d.ts +2 -0
  28. package/dist/getFilteredCompletions.test.d.ts.map +1 -0
  29. package/dist/getFilteredCompletions.test.js +202 -0
  30. package/dist/getFilteredCompletions.test.js.map +1 -0
  31. package/dist/index.d.ts +22 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +97 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/metaTags.d.ts +62 -0
  36. package/dist/metaTags.d.ts.map +1 -0
  37. package/dist/metaTags.js +116 -0
  38. package/dist/metaTags.js.map +1 -0
  39. package/dist/operatorReference.test.d.ts +2 -0
  40. package/dist/operatorReference.test.d.ts.map +1 -0
  41. package/dist/operatorReference.test.js +209 -0
  42. package/dist/operatorReference.test.js.map +1 -0
  43. package/dist/parseOperatorReference.d.ts +54 -0
  44. package/dist/parseOperatorReference.d.ts.map +1 -0
  45. package/dist/parseOperatorReference.js +103 -0
  46. package/dist/parseOperatorReference.js.map +1 -0
  47. package/dist/parseOperatorReference.test.d.ts +2 -0
  48. package/dist/parseOperatorReference.test.d.ts.map +1 -0
  49. package/dist/parseOperatorReference.test.js +151 -0
  50. package/dist/parseOperatorReference.test.js.map +1 -0
  51. package/dist/queryOperators.d.ts +2 -0
  52. package/dist/queryOperators.d.ts.map +1 -0
  53. package/dist/queryOperators.js +398 -0
  54. package/dist/queryOperators.js.map +1 -0
  55. package/dist/stages.d.ts +2 -0
  56. package/dist/stages.d.ts.map +1 -0
  57. package/dist/stages.js +265 -0
  58. package/dist/stages.js.map +1 -0
  59. package/dist/structuralInvariants.test.d.ts +2 -0
  60. package/dist/structuralInvariants.test.d.ts.map +1 -0
  61. package/dist/structuralInvariants.test.js +219 -0
  62. package/dist/structuralInvariants.test.js.map +1 -0
  63. package/dist/systemVariables.d.ts +2 -0
  64. package/dist/systemVariables.d.ts.map +1 -0
  65. package/dist/systemVariables.js +64 -0
  66. package/dist/systemVariables.js.map +1 -0
  67. package/dist/types.d.ts +139 -0
  68. package/dist/types.d.ts.map +1 -0
  69. package/dist/types.js +7 -0
  70. package/dist/types.js.map +1 -0
  71. package/dist/updateOperators.d.ts +2 -0
  72. package/dist/updateOperators.d.ts.map +1 -0
  73. package/dist/updateOperators.js +188 -0
  74. package/dist/updateOperators.js.map +1 -0
  75. package/dist/windowOperators.d.ts +2 -0
  76. package/dist/windowOperators.d.ts.map +1 -0
  77. package/dist/windowOperators.js +219 -0
  78. package/dist/windowOperators.js.map +1 -0
  79. package/package.json +25 -0
@@ -0,0 +1,1094 @@
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4
+ * Licensed under the MIT License. See License.txt in the project root for license information.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.loadExpressionOperators = loadExpressionOperators;
8
+ // AUTO-GENERATED — DO NOT EDIT BY HAND
9
+ //
10
+ // Generated by: npm run generate (scripts/generate-from-reference.ts)
11
+ // Sources: resources/scraped/operator-reference.md
12
+ // resources/overrides/operator-overrides.md
13
+ // resources/overrides/operator-snippets.md
14
+ //
15
+ // To change operator data, edit the overrides/snippets files and re-run the generator.
16
+ const docLinks_1 = require("./docLinks");
17
+ const getFilteredCompletions_1 = require("./getFilteredCompletions");
18
+ const metaTags_1 = require("./metaTags");
19
+ // ---------------------------------------------------------------------------
20
+ // Arithmetic Expression Operators
21
+ // ---------------------------------------------------------------------------
22
+ const arithmeticExpressionOperators = [
23
+ {
24
+ value: '$abs',
25
+ meta: metaTags_1.META_EXPR_ARITH,
26
+ description: 'The $abs operator returns the absolute value of a number.',
27
+ snippet: '{ $abs: "${1:\\$field}" }',
28
+ link: (0, docLinks_1.getDocLink)('$abs', metaTags_1.META_EXPR_ARITH),
29
+ },
30
+ {
31
+ value: '$add',
32
+ meta: metaTags_1.META_EXPR_ARITH,
33
+ description: 'The $add operator returns the sum of two numbers or the sum of a date and numbers.',
34
+ snippet: '{ $add: ["${1:\\$field1}", "${2:\\$field2}"] }',
35
+ link: (0, docLinks_1.getDocLink)('$add', metaTags_1.META_EXPR_ARITH),
36
+ },
37
+ {
38
+ value: '$ceil',
39
+ meta: metaTags_1.META_EXPR_ARITH,
40
+ description: 'The $ceil operator returns the smallest integer greater than or equal to the specified number.',
41
+ snippet: '{ $ceil: "${1:\\$field}" }',
42
+ link: (0, docLinks_1.getDocLink)('$ceil', metaTags_1.META_EXPR_ARITH),
43
+ },
44
+ {
45
+ value: '$divide',
46
+ meta: metaTags_1.META_EXPR_ARITH,
47
+ description: 'The $divide operator divides two numbers and returns the quotient.',
48
+ snippet: '{ $divide: ["${1:\\$field1}", "${2:\\$field2}"] }',
49
+ link: (0, docLinks_1.getDocLink)('$divide', metaTags_1.META_EXPR_ARITH),
50
+ },
51
+ {
52
+ value: '$exp',
53
+ meta: metaTags_1.META_EXPR_ARITH,
54
+ description: 'The $exp operator raises e to the specified exponent and returns the result',
55
+ snippet: '{ $exp: "${1:\\$field}" }',
56
+ link: (0, docLinks_1.getDocLink)('$exp', metaTags_1.META_EXPR_ARITH),
57
+ },
58
+ {
59
+ value: '$floor',
60
+ meta: metaTags_1.META_EXPR_ARITH,
61
+ description: 'The $floor operator returns the largest integer less than or equal to the specified number',
62
+ snippet: '{ $floor: "${1:\\$field}" }',
63
+ link: (0, docLinks_1.getDocLink)('$floor', metaTags_1.META_EXPR_ARITH),
64
+ },
65
+ {
66
+ value: '$ln',
67
+ meta: metaTags_1.META_EXPR_ARITH,
68
+ description: 'The $ln operator calculates the natural logarithm of the input',
69
+ snippet: '{ $ln: "${1:\\$field}" }',
70
+ link: (0, docLinks_1.getDocLink)('$ln', metaTags_1.META_EXPR_ARITH),
71
+ },
72
+ {
73
+ value: '$log',
74
+ meta: metaTags_1.META_EXPR_ARITH,
75
+ description: 'The $log operator calculates the logarithm of a number in the specified base',
76
+ snippet: '{ $log: ["${1:\\$number}", ${2:base}] }',
77
+ link: (0, docLinks_1.getDocLink)('$log', metaTags_1.META_EXPR_ARITH),
78
+ },
79
+ {
80
+ value: '$log10',
81
+ meta: metaTags_1.META_EXPR_ARITH,
82
+ description: 'The $log10 operator calculates the log of a specified number in base 10',
83
+ snippet: '{ $log10: "${1:\\$field}" }',
84
+ link: (0, docLinks_1.getDocLink)('$log10', metaTags_1.META_EXPR_ARITH),
85
+ },
86
+ {
87
+ value: '$mod',
88
+ meta: metaTags_1.META_EXPR_ARITH,
89
+ description: 'The $mod operator performs a modulo operation on the value of a field and selects documents with a specified result.',
90
+ snippet: '{ $mod: ["${1:\\$field1}", "${2:\\$field2}"] }',
91
+ link: 'https://learn.microsoft.com/en-us/azure/documentdb/operators/evaluation-query/$mod', // inferred from another category
92
+ },
93
+ {
94
+ value: '$multiply',
95
+ meta: metaTags_1.META_EXPR_ARITH,
96
+ description: 'The $multiply operator multiplies the input numerical values',
97
+ snippet: '{ $multiply: ["${1:\\$field1}", "${2:\\$field2}"] }',
98
+ link: (0, docLinks_1.getDocLink)('$multiply', metaTags_1.META_EXPR_ARITH),
99
+ },
100
+ {
101
+ value: '$pow',
102
+ meta: metaTags_1.META_EXPR_ARITH,
103
+ description: 'The `$pow` operator calculates the value of a numerical value raised to the power of a specified exponent.',
104
+ snippet: '{ $pow: ["${1:\\$field1}", "${2:\\$field2}"] }',
105
+ link: (0, docLinks_1.getDocLink)('$pow', metaTags_1.META_EXPR_ARITH),
106
+ },
107
+ {
108
+ value: '$round',
109
+ meta: metaTags_1.META_EXPR_ARITH,
110
+ description: 'The $round operator rounds a number to a specified decimal place.',
111
+ snippet: '{ $round: ["${1:\\$field}", ${2:place}] }',
112
+ link: (0, docLinks_1.getDocLink)('$round', metaTags_1.META_EXPR_ARITH),
113
+ },
114
+ {
115
+ value: '$sqrt',
116
+ meta: metaTags_1.META_EXPR_ARITH,
117
+ description: 'The $sqrt operator calculates and returns the square root of an input number',
118
+ snippet: '{ $sqrt: "${1:\\$field}" }',
119
+ link: (0, docLinks_1.getDocLink)('$sqrt', metaTags_1.META_EXPR_ARITH),
120
+ },
121
+ {
122
+ value: '$subtract',
123
+ meta: metaTags_1.META_EXPR_ARITH,
124
+ description: 'The $subtract operator subtracts two numbers and returns the result.',
125
+ snippet: '{ $subtract: ["${1:\\$field1}", "${2:\\$field2}"] }',
126
+ link: (0, docLinks_1.getDocLink)('$subtract', metaTags_1.META_EXPR_ARITH),
127
+ },
128
+ {
129
+ value: '$trunc',
130
+ meta: metaTags_1.META_EXPR_ARITH,
131
+ description: 'The $trunc operator truncates a number to a specified decimal place.',
132
+ snippet: '{ $trunc: "${1:\\$field}" }',
133
+ link: (0, docLinks_1.getDocLink)('$trunc', metaTags_1.META_EXPR_ARITH),
134
+ },
135
+ ];
136
+ // ---------------------------------------------------------------------------
137
+ // Array Expression Operators
138
+ // ---------------------------------------------------------------------------
139
+ const arrayExpressionOperators = [
140
+ {
141
+ value: '$arrayElemAt',
142
+ meta: metaTags_1.META_EXPR_ARRAY,
143
+ description: 'The $arrayElemAt returns the element at the specified array index.',
144
+ snippet: '{ $arrayElemAt: ["${1:\\$array}", ${2:index}] }',
145
+ link: (0, docLinks_1.getDocLink)('$arrayElemAt', metaTags_1.META_EXPR_ARRAY),
146
+ },
147
+ {
148
+ value: '$arrayToObject',
149
+ meta: metaTags_1.META_EXPR_ARRAY,
150
+ description: 'The $arrayToObject allows converting an array into a single document.',
151
+ snippet: '{ $arrayToObject: "${1:\\$array}" }',
152
+ link: (0, docLinks_1.getDocLink)('$arrayToObject', metaTags_1.META_EXPR_ARRAY),
153
+ },
154
+ {
155
+ value: '$concatArrays',
156
+ meta: metaTags_1.META_EXPR_ARRAY,
157
+ description: 'The $concatArrays is used to combine multiple arrays into a single array.',
158
+ snippet: '{ $concatArrays: ["${1:\\$array1}", "${2:\\$array2}"] }',
159
+ link: (0, docLinks_1.getDocLink)('$concatArrays', metaTags_1.META_EXPR_ARRAY),
160
+ },
161
+ {
162
+ value: '$filter',
163
+ meta: metaTags_1.META_EXPR_ARRAY,
164
+ description: 'The $filter operator filters for elements from an array based on a specified condition.',
165
+ snippet: '{ $filter: { input: "${1:\\$array}", as: "${2:item}", cond: { ${3:expression} } } }',
166
+ link: (0, docLinks_1.getDocLink)('$filter', metaTags_1.META_EXPR_ARRAY),
167
+ },
168
+ {
169
+ value: '$firstN',
170
+ meta: metaTags_1.META_EXPR_ARRAY,
171
+ description: 'The $firstN operator sorts documents on one or more fields specified by the query and returns the first N document matching the filtering criteria',
172
+ snippet: '{ $firstN: { input: "${1:\\$array}", n: ${2:number} } }',
173
+ link: 'https://learn.microsoft.com/en-us/azure/documentdb/operators/accumulators/$firstn', // inferred from another category
174
+ },
175
+ {
176
+ value: '$in',
177
+ meta: metaTags_1.META_EXPR_ARRAY,
178
+ description: 'The $in operator matches value of a field against an array of specified values',
179
+ snippet: '{ $in: ["${1:\\$field}", "${2:\\$array}"] }',
180
+ link: 'https://learn.microsoft.com/en-us/azure/documentdb/operators/comparison-query/$in', // inferred from another category
181
+ },
182
+ {
183
+ value: '$indexOfArray',
184
+ meta: metaTags_1.META_EXPR_ARRAY,
185
+ description: 'The $indexOfArray operator is used to search for an element in an array and return the index of the first occurrence of the element.',
186
+ snippet: '{ $indexOfArray: ["${1:\\$array}", "${2:value}"] }',
187
+ link: (0, docLinks_1.getDocLink)('$indexOfArray', metaTags_1.META_EXPR_ARRAY),
188
+ },
189
+ {
190
+ value: '$isArray',
191
+ meta: metaTags_1.META_EXPR_ARRAY,
192
+ description: 'The $isArray operator is used to determine if a specified value is an array.',
193
+ snippet: '{ $isArray: "${1:\\$field}" }',
194
+ link: (0, docLinks_1.getDocLink)('$isArray', metaTags_1.META_EXPR_ARRAY),
195
+ },
196
+ {
197
+ value: '$lastN',
198
+ meta: metaTags_1.META_EXPR_ARRAY,
199
+ description: 'The $lastN accumulator operator returns the last N values in a group of documents.',
200
+ snippet: '{ $lastN: { input: "${1:\\$array}", n: ${2:number} } }',
201
+ link: 'https://learn.microsoft.com/en-us/azure/documentdb/operators/accumulators/$lastn', // inferred from another category
202
+ },
203
+ {
204
+ value: '$map',
205
+ meta: metaTags_1.META_EXPR_ARRAY,
206
+ description: 'The $map operator allows applying an expression to each element in an array.',
207
+ snippet: '{ $map: { input: "${1:\\$array}", as: "${2:item}", in: { ${3:expression} } } }',
208
+ link: (0, docLinks_1.getDocLink)('$map', metaTags_1.META_EXPR_ARRAY),
209
+ },
210
+ {
211
+ value: '$maxN',
212
+ meta: metaTags_1.META_EXPR_ARRAY,
213
+ description: 'Retrieves the top N values based on a specified filtering criteria',
214
+ snippet: '{ $maxN: { input: "${1:\\$array}", n: ${2:number} } }',
215
+ link: 'https://learn.microsoft.com/en-us/azure/documentdb/operators/accumulators/$maxn', // inferred from another category
216
+ },
217
+ {
218
+ value: '$minN',
219
+ meta: metaTags_1.META_EXPR_ARRAY,
220
+ description: 'Retrieves the bottom N values based on a specified filtering criteria',
221
+ snippet: '{ $minN: { input: "${1:\\$array}", n: ${2:number} } }',
222
+ link: 'https://learn.microsoft.com/en-us/azure/documentdb/operators/accumulators/$minn',
223
+ },
224
+ {
225
+ value: '$objectToArray',
226
+ meta: metaTags_1.META_EXPR_ARRAY,
227
+ description: 'Converts an object into an array of key-value pair documents.',
228
+ snippet: '{ $objectToArray: "${1:\\$object}" }',
229
+ link: 'https://learn.microsoft.com/en-us/azure/documentdb/operators/object-expression/$objecttoarray', // inferred from another category
230
+ },
231
+ {
232
+ value: '$range',
233
+ meta: metaTags_1.META_EXPR_ARRAY,
234
+ description: 'The $range operator allows generating an array of sequential integers.',
235
+ snippet: '{ $range: [${1:start}, ${2:end}, ${3:step}] }',
236
+ link: (0, docLinks_1.getDocLink)('$range', metaTags_1.META_EXPR_ARRAY),
237
+ },
238
+ {
239
+ value: '$reduce',
240
+ meta: metaTags_1.META_EXPR_ARRAY,
241
+ description: 'The $reduce operator applies an expression to each element in an array & accumulate result as single value.',
242
+ snippet: '{ $reduce: { input: "${1:\\$array}", initialValue: ${2:0}, in: { ${3:expression} } } }',
243
+ link: (0, docLinks_1.getDocLink)('$reduce', metaTags_1.META_EXPR_ARRAY),
244
+ },
245
+ {
246
+ value: '$reverseArray',
247
+ meta: metaTags_1.META_EXPR_ARRAY,
248
+ description: 'The $reverseArray operator is used to reverse the order of elements in an array.',
249
+ snippet: '{ $reverseArray: "${1:\\$array}" }',
250
+ link: (0, docLinks_1.getDocLink)('$reverseArray', metaTags_1.META_EXPR_ARRAY),
251
+ },
252
+ {
253
+ value: '$size',
254
+ meta: metaTags_1.META_EXPR_ARRAY,
255
+ description: 'The $size operator is used to query documents where an array field has a specified number of elements.',
256
+ snippet: '{ $size: "${1:\\$array}" }',
257
+ link: 'https://learn.microsoft.com/en-us/azure/documentdb/operators/array-query/$size', // inferred from another category
258
+ },
259
+ {
260
+ value: '$slice',
261
+ meta: metaTags_1.META_EXPR_ARRAY,
262
+ description: 'The $slice operator returns a subset of an array from any element onwards in the array.',
263
+ snippet: '{ $slice: ["${1:\\$array}", ${2:n}] }',
264
+ link: (0, docLinks_1.getDocLink)('$slice', metaTags_1.META_EXPR_ARRAY),
265
+ },
266
+ {
267
+ value: '$sortArray',
268
+ meta: metaTags_1.META_EXPR_ARRAY,
269
+ description: 'The $sortArray operator helps in sorting the elements in an array.',
270
+ snippet: '{ $sortArray: { input: "${1:\\$array}", sortBy: { ${2:field}: ${3:1} } } }',
271
+ link: (0, docLinks_1.getDocLink)('$sortArray', metaTags_1.META_EXPR_ARRAY),
272
+ },
273
+ {
274
+ value: '$zip',
275
+ meta: metaTags_1.META_EXPR_ARRAY,
276
+ description: 'The $zip operator allows merging two or more arrays element-wise into a single array or arrays.',
277
+ snippet: '{ $zip: { inputs: ["${1:\\$array1}", "${2:\\$array2}"] } }',
278
+ link: (0, docLinks_1.getDocLink)('$zip', metaTags_1.META_EXPR_ARRAY),
279
+ },
280
+ ];
281
+ // ---------------------------------------------------------------------------
282
+ // Bitwise Operators
283
+ // ---------------------------------------------------------------------------
284
+ const bitwiseOperators = [
285
+ {
286
+ value: '$bitAnd',
287
+ meta: metaTags_1.META_EXPR_BITWISE,
288
+ description: 'The $bitAnd operator performs a bitwise AND operation on integer values and returns the result as an integer.',
289
+ snippet: '{ $bitAnd: [${1:value1}, ${2:value2}] }',
290
+ link: (0, docLinks_1.getDocLink)('$bitAnd', metaTags_1.META_EXPR_BITWISE),
291
+ },
292
+ {
293
+ value: '$bitNot',
294
+ meta: metaTags_1.META_EXPR_BITWISE,
295
+ description: 'The $bitNot operator performs a bitwise NOT operation on integer values and returns the result as an integer.',
296
+ snippet: '{ $bitNot: "${1:\\$field}" }',
297
+ link: (0, docLinks_1.getDocLink)('$bitNot', metaTags_1.META_EXPR_BITWISE),
298
+ },
299
+ {
300
+ value: '$bitOr',
301
+ meta: metaTags_1.META_EXPR_BITWISE,
302
+ description: 'The $bitOr operator performs a bitwise OR operation on integer values and returns the result as an integer.',
303
+ snippet: '{ $bitOr: [${1:value1}, ${2:value2}] }',
304
+ link: (0, docLinks_1.getDocLink)('$bitOr', metaTags_1.META_EXPR_BITWISE),
305
+ },
306
+ {
307
+ value: '$bitXor',
308
+ meta: metaTags_1.META_EXPR_BITWISE,
309
+ description: 'The $bitXor operator performs a bitwise XOR operation on integer values.',
310
+ snippet: '{ $bitXor: [${1:value1}, ${2:value2}] }',
311
+ link: (0, docLinks_1.getDocLink)('$bitXor', metaTags_1.META_EXPR_BITWISE),
312
+ },
313
+ ];
314
+ // ---------------------------------------------------------------------------
315
+ // Boolean Expression Operators
316
+ // ---------------------------------------------------------------------------
317
+ const booleanExpressionOperators = [
318
+ {
319
+ value: '$and',
320
+ meta: metaTags_1.META_EXPR_BOOL,
321
+ description: 'The $and operator joins multiple query clauses and returns documents that match all specified conditions.',
322
+ snippet: '{ $and: ["${1:expression1}", "${2:expression2}"] }',
323
+ link: 'https://learn.microsoft.com/en-us/azure/documentdb/operators/logical-query/$and', // inferred from another category
324
+ },
325
+ {
326
+ value: '$not',
327
+ meta: metaTags_1.META_EXPR_BOOL,
328
+ description: "The $not operator performs a logical NOT operation on a specified expression, selecting documents that don't match the expression.",
329
+ snippet: '{ $not: ["${1:expression}"] }',
330
+ link: 'https://learn.microsoft.com/en-us/azure/documentdb/operators/logical-query/$not', // inferred from another category
331
+ },
332
+ {
333
+ value: '$or',
334
+ meta: metaTags_1.META_EXPR_BOOL,
335
+ description: 'The $or operator joins query clauses with a logical OR and returns documents that match at least one of the specified conditions.',
336
+ snippet: '{ $or: ["${1:expression1}", "${2:expression2}"] }',
337
+ link: 'https://learn.microsoft.com/en-us/azure/documentdb/operators/logical-query/$or', // inferred from another category
338
+ },
339
+ ];
340
+ // ---------------------------------------------------------------------------
341
+ // Comparison Expression Operators
342
+ // ---------------------------------------------------------------------------
343
+ const comparisonExpressionOperators = [
344
+ {
345
+ value: '$cmp',
346
+ meta: metaTags_1.META_EXPR_COMPARISON,
347
+ description: 'The $cmp operator compares two values',
348
+ snippet: '{ $cmp: ["${1:\\$field1}", "${2:\\$field2}"] }',
349
+ link: 'https://learn.microsoft.com/en-us/azure/documentdb/operators/comparison-query/$cmp',
350
+ },
351
+ {
352
+ value: '$eq',
353
+ meta: metaTags_1.META_EXPR_COMPARISON,
354
+ description: 'The $eq query operator compares the value of a field to a specified value',
355
+ snippet: '{ $eq: ["${1:\\$field1}", "${2:\\$field2}"] }',
356
+ link: 'https://learn.microsoft.com/en-us/azure/documentdb/operators/comparison-query/$eq', // inferred from another category
357
+ },
358
+ {
359
+ value: '$gt',
360
+ meta: metaTags_1.META_EXPR_COMPARISON,
361
+ description: 'The $gt query operator retrieves documents where the value of a field is greater than a specified value',
362
+ snippet: '{ $gt: ["${1:\\$field1}", "${2:\\$field2}"] }',
363
+ link: 'https://learn.microsoft.com/en-us/azure/documentdb/operators/comparison-query/$gt', // inferred from another category
364
+ },
365
+ {
366
+ value: '$gte',
367
+ meta: metaTags_1.META_EXPR_COMPARISON,
368
+ description: 'The $gte operator retrieves documents where the value of a field is greater than or equal to a specified value',
369
+ snippet: '{ $gte: ["${1:\\$field1}", "${2:\\$field2}"] }',
370
+ link: 'https://learn.microsoft.com/en-us/azure/documentdb/operators/comparison-query/$gte', // inferred from another category
371
+ },
372
+ {
373
+ value: '$lt',
374
+ meta: metaTags_1.META_EXPR_COMPARISON,
375
+ description: 'The $lt operator retrieves documents where the value of field is less than a specified value',
376
+ snippet: '{ $lt: ["${1:\\$field1}", "${2:\\$field2}"] }',
377
+ link: 'https://learn.microsoft.com/en-us/azure/documentdb/operators/comparison-query/$lt', // inferred from another category
378
+ },
379
+ {
380
+ value: '$lte',
381
+ meta: metaTags_1.META_EXPR_COMPARISON,
382
+ description: 'The $lte operator retrieves documents where the value of a field is less than or equal to a specified value',
383
+ snippet: '{ $lte: ["${1:\\$field1}", "${2:\\$field2}"] }',
384
+ link: 'https://learn.microsoft.com/en-us/azure/documentdb/operators/comparison-query/$lte', // inferred from another category
385
+ },
386
+ {
387
+ value: '$ne',
388
+ meta: metaTags_1.META_EXPR_COMPARISON,
389
+ description: "The $ne operator retrieves documents where the value of a field doesn't equal a specified value",
390
+ snippet: '{ $ne: ["${1:\\$field1}", "${2:\\$field2}"] }',
391
+ link: 'https://learn.microsoft.com/en-us/azure/documentdb/operators/comparison-query/$ne', // inferred from another category
392
+ },
393
+ ];
394
+ // ---------------------------------------------------------------------------
395
+ // Data Size Operators
396
+ // ---------------------------------------------------------------------------
397
+ const dataSizeOperators = [
398
+ {
399
+ value: '$bsonSize',
400
+ meta: metaTags_1.META_EXPR_DATASIZE,
401
+ description: 'The $bsonSize operator returns the size of a document in bytes when encoded as BSON.',
402
+ snippet: '{ $bsonSize: "${1:\\$field}" }',
403
+ link: (0, docLinks_1.getDocLink)('$bsonSize', metaTags_1.META_EXPR_DATASIZE),
404
+ },
405
+ {
406
+ value: '$binarySize',
407
+ meta: metaTags_1.META_EXPR_DATASIZE,
408
+ description: 'The $binarySize operator is used to return the size of a binary data field.',
409
+ snippet: '{ $binarySize: "${1:\\$field}" }',
410
+ link: (0, docLinks_1.getDocLink)('$binarySize', metaTags_1.META_EXPR_DATASIZE),
411
+ },
412
+ ];
413
+ // ---------------------------------------------------------------------------
414
+ // Date Expression Operators
415
+ // ---------------------------------------------------------------------------
416
+ const dateExpressionOperators = [
417
+ {
418
+ value: '$dateAdd',
419
+ meta: metaTags_1.META_EXPR_DATE,
420
+ description: 'The $dateAdd operator adds a specified number of time units (day, hour, month etc) to a date.',
421
+ snippet: '{ $dateAdd: { startDate: "${1:\\$dateField}", unit: "${2:day}", amount: ${3:1} } }',
422
+ link: (0, docLinks_1.getDocLink)('$dateAdd', metaTags_1.META_EXPR_DATE),
423
+ },
424
+ {
425
+ value: '$dateDiff',
426
+ meta: metaTags_1.META_EXPR_DATE,
427
+ description: 'The $dateDiff operator calculates the difference between two dates in various units such as years, months, days, etc.',
428
+ snippet: '{ $dateDiff: { startDate: "${1:\\$startDate}", endDate: "${2:\\$endDate}", unit: "${3:day}" } }',
429
+ link: (0, docLinks_1.getDocLink)('$dateDiff', metaTags_1.META_EXPR_DATE),
430
+ },
431
+ {
432
+ value: '$dateFromParts',
433
+ meta: metaTags_1.META_EXPR_DATE,
434
+ description: 'The $dateFromParts operator constructs a date from individual components.',
435
+ snippet: '{ $dateFromParts: { year: ${1:2024}, month: ${2:1}, day: ${3:1} } }',
436
+ link: (0, docLinks_1.getDocLink)('$dateFromParts', metaTags_1.META_EXPR_DATE),
437
+ },
438
+ {
439
+ value: '$dateFromString',
440
+ meta: metaTags_1.META_EXPR_DATE,
441
+ description: 'The $dateDiff operator converts a date/time string to a date object.',
442
+ snippet: '{ $dateFromString: { dateString: "${1:dateString}" } }',
443
+ link: (0, docLinks_1.getDocLink)('$dateFromString', metaTags_1.META_EXPR_DATE),
444
+ },
445
+ {
446
+ value: '$dateSubtract',
447
+ meta: metaTags_1.META_EXPR_DATE,
448
+ description: 'The $dateSubtract operator subtracts a specified amount of time from a date.',
449
+ snippet: '{ $dateSubtract: { startDate: "${1:\\$dateField}", unit: "${2:day}", amount: ${3:1} } }',
450
+ link: (0, docLinks_1.getDocLink)('$dateSubtract', metaTags_1.META_EXPR_DATE),
451
+ },
452
+ {
453
+ value: '$dateToParts',
454
+ meta: metaTags_1.META_EXPR_DATE,
455
+ description: 'The $dateToParts operator decomposes a date into its individual parts such as year, month, day, and more.',
456
+ snippet: '{ $dateToParts: { date: "${1:\\$dateField}" } }',
457
+ link: (0, docLinks_1.getDocLink)('$dateToParts', metaTags_1.META_EXPR_DATE),
458
+ },
459
+ {
460
+ value: '$dateToString',
461
+ meta: metaTags_1.META_EXPR_DATE,
462
+ description: 'The $dateToString operator converts a date object into a formatted string.',
463
+ snippet: '{ $dateToString: { format: "${1:%Y-%m-%d}", date: "${2:\\$dateField}" } }',
464
+ link: (0, docLinks_1.getDocLink)('$dateToString', metaTags_1.META_EXPR_DATE),
465
+ },
466
+ {
467
+ value: '$dateTrunc',
468
+ meta: metaTags_1.META_EXPR_DATE,
469
+ description: 'The $dateTrunc operator truncates a date to a specified unit.',
470
+ snippet: '{ $dateTrunc: { date: "${1:\\$dateField}", unit: "${2:day}" } }',
471
+ link: (0, docLinks_1.getDocLink)('$dateTrunc', metaTags_1.META_EXPR_DATE),
472
+ },
473
+ {
474
+ value: '$dayOfMonth',
475
+ meta: metaTags_1.META_EXPR_DATE,
476
+ description: 'The $dayOfMonth operator extracts the day of the month from a date.',
477
+ snippet: '{ $dayOfMonth: "${1:\\$dateField}" }',
478
+ link: (0, docLinks_1.getDocLink)('$dayOfMonth', metaTags_1.META_EXPR_DATE),
479
+ },
480
+ {
481
+ value: '$dayOfWeek',
482
+ meta: metaTags_1.META_EXPR_DATE,
483
+ description: 'The $dayOfWeek operator extracts the day of the week from a date.',
484
+ snippet: '{ $dayOfWeek: "${1:\\$dateField}" }',
485
+ link: (0, docLinks_1.getDocLink)('$dayOfWeek', metaTags_1.META_EXPR_DATE),
486
+ },
487
+ {
488
+ value: '$dayOfYear',
489
+ meta: metaTags_1.META_EXPR_DATE,
490
+ description: 'The $dayOfYear operator extracts the day of the year from a date.',
491
+ snippet: '{ $dayOfYear: "${1:\\$dateField}" }',
492
+ link: (0, docLinks_1.getDocLink)('$dayOfYear', metaTags_1.META_EXPR_DATE),
493
+ },
494
+ {
495
+ value: '$hour',
496
+ meta: metaTags_1.META_EXPR_DATE,
497
+ description: 'The $hour operator returns the hour portion of a date as a number between 0 and 23.',
498
+ snippet: '{ $hour: "${1:\\$dateField}" }',
499
+ link: (0, docLinks_1.getDocLink)('$hour', metaTags_1.META_EXPR_DATE),
500
+ },
501
+ {
502
+ value: '$isoDayOfWeek',
503
+ meta: metaTags_1.META_EXPR_DATE,
504
+ description: 'The $isoDayOfWeek operator returns the weekday number in ISO 8601 format, ranging from 1 (Monday) to 7 (Sunday).',
505
+ snippet: '{ $isoDayOfWeek: "${1:\\$dateField}" }',
506
+ link: (0, docLinks_1.getDocLink)('$isoDayOfWeek', metaTags_1.META_EXPR_DATE),
507
+ },
508
+ {
509
+ value: '$isoWeek',
510
+ meta: metaTags_1.META_EXPR_DATE,
511
+ description: 'The $isoWeek operator returns the week number of the year in ISO 8601 format, ranging from 1 to 53.',
512
+ snippet: '{ $isoWeek: "${1:\\$dateField}" }',
513
+ link: (0, docLinks_1.getDocLink)('$isoWeek', metaTags_1.META_EXPR_DATE),
514
+ },
515
+ {
516
+ value: '$isoWeekYear',
517
+ meta: metaTags_1.META_EXPR_DATE,
518
+ description: 'The $isoWeekYear operator returns the year number in ISO 8601 format, which can differ from the calendar year for dates at the beginning or end of the year.',
519
+ snippet: '{ $isoWeekYear: "${1:\\$dateField}" }',
520
+ link: (0, docLinks_1.getDocLink)('$isoWeekYear', metaTags_1.META_EXPR_DATE),
521
+ },
522
+ {
523
+ value: '$millisecond',
524
+ meta: metaTags_1.META_EXPR_DATE,
525
+ description: 'The $millisecond operator extracts the milliseconds portion from a date value.',
526
+ snippet: '{ $millisecond: "${1:\\$dateField}" }',
527
+ link: (0, docLinks_1.getDocLink)('$millisecond', metaTags_1.META_EXPR_DATE),
528
+ },
529
+ {
530
+ value: '$minute',
531
+ meta: metaTags_1.META_EXPR_DATE,
532
+ description: 'The $minute operator extracts the minute portion from a date value.',
533
+ snippet: '{ $minute: "${1:\\$dateField}" }',
534
+ link: (0, docLinks_1.getDocLink)('$minute', metaTags_1.META_EXPR_DATE),
535
+ },
536
+ {
537
+ value: '$month',
538
+ meta: metaTags_1.META_EXPR_DATE,
539
+ description: 'The $month operator extracts the month portion from a date value.',
540
+ snippet: '{ $month: "${1:\\$dateField}" }',
541
+ link: (0, docLinks_1.getDocLink)('$month', metaTags_1.META_EXPR_DATE),
542
+ },
543
+ {
544
+ value: '$second',
545
+ meta: metaTags_1.META_EXPR_DATE,
546
+ description: 'The $second operator extracts the seconds portion from a date value.',
547
+ snippet: '{ $second: "${1:\\$dateField}" }',
548
+ link: (0, docLinks_1.getDocLink)('$second', metaTags_1.META_EXPR_DATE),
549
+ },
550
+ {
551
+ value: '$toDate',
552
+ meta: metaTags_1.META_EXPR_DATE,
553
+ description: 'The $toDate operator converts supported types to a proper Date object.',
554
+ snippet: '{ $toDate: "${1:\\$field}" }',
555
+ link: 'https://learn.microsoft.com/en-us/azure/documentdb/operators/aggregation/type-expression/$todate', // inferred from another category
556
+ },
557
+ {
558
+ value: '$week',
559
+ meta: metaTags_1.META_EXPR_DATE,
560
+ description: 'The $week operator returns the week number for a date as a value between 0 and 53.',
561
+ snippet: '{ $week: "${1:\\$dateField}" }',
562
+ link: (0, docLinks_1.getDocLink)('$week', metaTags_1.META_EXPR_DATE),
563
+ },
564
+ {
565
+ value: '$year',
566
+ meta: metaTags_1.META_EXPR_DATE,
567
+ description: 'The $year operator returns the year for a date as a four-digit number.',
568
+ snippet: '{ $year: "${1:\\$dateField}" }',
569
+ link: (0, docLinks_1.getDocLink)('$year', metaTags_1.META_EXPR_DATE),
570
+ },
571
+ ];
572
+ // ---------------------------------------------------------------------------
573
+ // Literal Expression Operator
574
+ // ---------------------------------------------------------------------------
575
+ const literalExpressionOperator = [
576
+ {
577
+ value: '$literal',
578
+ meta: metaTags_1.META_EXPR_LITERAL,
579
+ description: 'The $literal operator returns the specified value without parsing it as an expression, allowing literal values to be used in aggregation pipelines.',
580
+ snippet: '{ $literal: ${1:value} }',
581
+ link: (0, docLinks_1.getDocLink)('$literal', metaTags_1.META_EXPR_LITERAL),
582
+ },
583
+ ];
584
+ // ---------------------------------------------------------------------------
585
+ // Miscellaneous Operators
586
+ // ---------------------------------------------------------------------------
587
+ const miscellaneousOperators = [
588
+ {
589
+ value: '$getField',
590
+ meta: metaTags_1.META_EXPR_MISC,
591
+ description: 'The $getField operator allows retrieving the value of a specified field from a document.',
592
+ snippet: '{ $getField: { field: "${1:fieldName}", input: "${2:\\$object}" } }',
593
+ link: (0, docLinks_1.getDocLink)('$getField', metaTags_1.META_EXPR_MISC),
594
+ },
595
+ {
596
+ value: '$rand',
597
+ meta: metaTags_1.META_EXPR_MISC,
598
+ description: 'The $rand operator generates a random float value between 0 and 1.',
599
+ snippet: '{ $rand: {} }',
600
+ link: 'https://learn.microsoft.com/en-us/azure/documentdb/operators/miscellaneous-query/$rand', // inferred from another category
601
+ },
602
+ {
603
+ value: '$sampleRate',
604
+ meta: metaTags_1.META_EXPR_MISC,
605
+ description: 'The $sampleRate operator randomly samples documents from a collection based on a specified probability rate, useful for statistical analysis and testing.',
606
+ snippet: '{ $sampleRate: ${1:0.5} }',
607
+ link: (0, docLinks_1.getDocLink)('$sampleRate', metaTags_1.META_EXPR_MISC),
608
+ },
609
+ ];
610
+ // ---------------------------------------------------------------------------
611
+ // Object Expression Operators
612
+ // ---------------------------------------------------------------------------
613
+ const objectExpressionOperators = [
614
+ {
615
+ value: '$mergeObjects',
616
+ meta: metaTags_1.META_EXPR_OBJECT,
617
+ description: 'The $mergeObjects operator merges multiple documents into a single document',
618
+ snippet: '{ $mergeObjects: ["${1:\\$object1}", "${2:\\$object2}"] }',
619
+ link: (0, docLinks_1.getDocLink)('$mergeObjects', metaTags_1.META_EXPR_OBJECT),
620
+ },
621
+ {
622
+ value: '$objectToArray',
623
+ meta: metaTags_1.META_EXPR_OBJECT,
624
+ description: 'The objectToArray command is used to transform a document (object) into an array of key-value pairs.',
625
+ snippet: '{ $objectToArray: "${1:\\$object}" }',
626
+ link: (0, docLinks_1.getDocLink)('$objectToArray', metaTags_1.META_EXPR_OBJECT),
627
+ },
628
+ {
629
+ value: '$setField',
630
+ meta: metaTags_1.META_EXPR_OBJECT,
631
+ description: 'The setField command is used to add, update, or remove fields in embedded documents.',
632
+ snippet: '{ $setField: { field: "${1:fieldName}", input: "${2:\\$object}", value: ${3:value} } }',
633
+ link: (0, docLinks_1.getDocLink)('$setField', metaTags_1.META_EXPR_OBJECT),
634
+ },
635
+ ];
636
+ // ---------------------------------------------------------------------------
637
+ // Set Expression Operators
638
+ // ---------------------------------------------------------------------------
639
+ const setExpressionOperators = [
640
+ {
641
+ value: '$allElementsTrue',
642
+ meta: metaTags_1.META_EXPR_SET,
643
+ description: 'The $allElementsTrue operator returns true if all elements in an array evaluate to true.',
644
+ snippet: '{ $allElementsTrue: ["${1:\\$array}"] }',
645
+ link: (0, docLinks_1.getDocLink)('$allElementsTrue', metaTags_1.META_EXPR_SET),
646
+ },
647
+ {
648
+ value: '$anyElementTrue',
649
+ meta: metaTags_1.META_EXPR_SET,
650
+ description: 'The $anyElementTrue operator returns true if any element in an array evaluates to a value of true.',
651
+ snippet: '{ $anyElementTrue: ["${1:\\$array}"] }',
652
+ link: (0, docLinks_1.getDocLink)('$anyElementTrue', metaTags_1.META_EXPR_SET),
653
+ },
654
+ {
655
+ value: '$setDifference',
656
+ meta: metaTags_1.META_EXPR_SET,
657
+ description: 'The $setDifference operator returns a set with elements that exist in one set but not in a second set.',
658
+ snippet: '{ $setDifference: ["${1:\\$set1}", "${2:\\$set2}"] }',
659
+ link: (0, docLinks_1.getDocLink)('$setDifference', metaTags_1.META_EXPR_SET),
660
+ },
661
+ {
662
+ value: '$setEquals',
663
+ meta: metaTags_1.META_EXPR_SET,
664
+ description: 'The $setEquals operator returns true if two sets have the same distinct elements.',
665
+ snippet: '{ $setEquals: ["${1:\\$set1}", "${2:\\$set2}"] }',
666
+ link: (0, docLinks_1.getDocLink)('$setEquals', metaTags_1.META_EXPR_SET),
667
+ },
668
+ {
669
+ value: '$setIntersection',
670
+ meta: metaTags_1.META_EXPR_SET,
671
+ description: 'The $setIntersection operator returns the common elements that appear in all input arrays.',
672
+ snippet: '{ $setIntersection: ["${1:\\$set1}", "${2:\\$set2}"] }',
673
+ link: (0, docLinks_1.getDocLink)('$setIntersection', metaTags_1.META_EXPR_SET),
674
+ },
675
+ {
676
+ value: '$setIsSubset',
677
+ meta: metaTags_1.META_EXPR_SET,
678
+ description: 'The $setIsSubset operator determines if one array is a subset of a second array.',
679
+ snippet: '{ $setIsSubset: ["${1:\\$set1}", "${2:\\$set2}"] }',
680
+ link: (0, docLinks_1.getDocLink)('$setIsSubset', metaTags_1.META_EXPR_SET),
681
+ },
682
+ {
683
+ value: '$setUnion',
684
+ meta: metaTags_1.META_EXPR_SET,
685
+ description: 'The $setUnion operator returns an array that contains all the unique elements from the input arrays.',
686
+ snippet: '{ $setUnion: ["${1:\\$set1}", "${2:\\$set2}"] }',
687
+ link: (0, docLinks_1.getDocLink)('$setUnion', metaTags_1.META_EXPR_SET),
688
+ },
689
+ ];
690
+ // ---------------------------------------------------------------------------
691
+ // String Expression Operators
692
+ // ---------------------------------------------------------------------------
693
+ const stringExpressionOperators = [
694
+ {
695
+ value: '$concat',
696
+ meta: metaTags_1.META_EXPR_STRING,
697
+ description: 'Concatenates two or more strings and returns the resulting string.',
698
+ snippet: '{ $concat: ["${1:\\$string1}", "${2:\\$string2}"] }',
699
+ },
700
+ {
701
+ value: '$dateFromString',
702
+ meta: metaTags_1.META_EXPR_STRING,
703
+ description: 'The $dateDiff operator converts a date/time string to a date object.',
704
+ snippet: '{ $dateFromString: "${1:\\$string}" }',
705
+ link: 'https://learn.microsoft.com/en-us/azure/documentdb/operators/date-expression/$datefromstring', // inferred from another category
706
+ },
707
+ {
708
+ value: '$dateToString',
709
+ meta: metaTags_1.META_EXPR_STRING,
710
+ description: 'The $dateToString operator converts a date object into a formatted string.',
711
+ snippet: '{ $dateToString: "${1:\\$string}" }',
712
+ link: 'https://learn.microsoft.com/en-us/azure/documentdb/operators/date-expression/$datetostring', // inferred from another category
713
+ },
714
+ {
715
+ value: '$indexOfBytes',
716
+ meta: metaTags_1.META_EXPR_STRING,
717
+ description: 'Returns the byte index of the first occurrence of a substring within a string.',
718
+ snippet: '{ $indexOfBytes: ["${1:\\$string}", "${2:substring}"] }',
719
+ },
720
+ {
721
+ value: '$indexOfCP',
722
+ meta: metaTags_1.META_EXPR_STRING,
723
+ description: 'Returns the code point index of the first occurrence of a substring within a string.',
724
+ snippet: '{ $indexOfCP: ["${1:\\$string}", "${2:substring}"] }',
725
+ },
726
+ {
727
+ value: '$ltrim',
728
+ meta: metaTags_1.META_EXPR_STRING,
729
+ description: 'Removes whitespace or specified characters from the beginning of a string.',
730
+ snippet: '{ $ltrim: { input: "${1:\\$string}" } }',
731
+ },
732
+ {
733
+ value: '$regexFind',
734
+ meta: metaTags_1.META_EXPR_STRING,
735
+ description: 'Applies a regular expression to a string and returns the first match.',
736
+ snippet: '{ $regexFind: { input: "${1:\\$string}", regex: "${2:pattern}" } }',
737
+ },
738
+ {
739
+ value: '$regexFindAll',
740
+ meta: metaTags_1.META_EXPR_STRING,
741
+ description: 'Applies a regular expression to a string and returns all matches as an array.',
742
+ snippet: '{ $regexFindAll: { input: "${1:\\$string}", regex: "${2:pattern}" } }',
743
+ },
744
+ {
745
+ value: '$regexMatch',
746
+ meta: metaTags_1.META_EXPR_STRING,
747
+ description: 'Applies a regular expression to a string and returns a boolean indicating if a match was found.',
748
+ snippet: '{ $regexMatch: { input: "${1:\\$string}", regex: "${2:pattern}" } }',
749
+ },
750
+ {
751
+ value: '$replaceOne',
752
+ meta: metaTags_1.META_EXPR_STRING,
753
+ description: 'Replaces the first occurrence of a search string with a replacement string.',
754
+ snippet: '{ $replaceOne: { input: "${1:\\$string}", find: "${2:find}", replacement: "${3:replacement}" } }',
755
+ },
756
+ {
757
+ value: '$replaceAll',
758
+ meta: metaTags_1.META_EXPR_STRING,
759
+ description: 'Replaces all occurrences of a search string with a replacement string.',
760
+ snippet: '{ $replaceAll: { input: "${1:\\$string}", find: "${2:find}", replacement: "${3:replacement}" } }',
761
+ },
762
+ {
763
+ value: '$rtrim',
764
+ meta: metaTags_1.META_EXPR_STRING,
765
+ description: 'Removes whitespace or specified characters from the end of a string.',
766
+ snippet: '{ $rtrim: { input: "${1:\\$string}" } }',
767
+ },
768
+ {
769
+ value: '$split',
770
+ meta: metaTags_1.META_EXPR_STRING,
771
+ description: 'Splits a string by a delimiter and returns an array of substrings.',
772
+ snippet: '{ $split: ["${1:\\$string}", "${2:delimiter}"] }',
773
+ },
774
+ {
775
+ value: '$strLenBytes',
776
+ meta: metaTags_1.META_EXPR_STRING,
777
+ description: 'Returns the number of UTF-8 encoded bytes in the specified string.',
778
+ snippet: '{ $strLenBytes: "${1:\\$string}" }',
779
+ },
780
+ {
781
+ value: '$strLenCP',
782
+ meta: metaTags_1.META_EXPR_STRING,
783
+ description: 'Returns the number of UTF-8 code points in the specified string.',
784
+ snippet: '{ $strLenCP: "${1:\\$string}" }',
785
+ },
786
+ {
787
+ value: '$strcasecmp',
788
+ meta: metaTags_1.META_EXPR_STRING,
789
+ description: 'Performs a case-insensitive comparison of two strings and returns an integer.',
790
+ snippet: '{ $strcasecmp: ["${1:\\$string1}", "${2:\\$string2}"] }',
791
+ },
792
+ {
793
+ value: '$substr',
794
+ meta: metaTags_1.META_EXPR_STRING,
795
+ description: 'Returns a substring of a string, starting at a specified index for a specified length. Deprecated — use $substrBytes or $substrCP.',
796
+ snippet: '{ $substr: ["${1:\\$string}", ${2:start}, ${3:length}] }',
797
+ },
798
+ {
799
+ value: '$substrBytes',
800
+ meta: metaTags_1.META_EXPR_STRING,
801
+ description: 'Returns a substring of a string by byte index, starting at a specified index for a specified number of bytes.',
802
+ snippet: '{ $substrBytes: ["${1:\\$string}", ${2:start}, ${3:length}] }',
803
+ },
804
+ {
805
+ value: '$substrCP',
806
+ meta: metaTags_1.META_EXPR_STRING,
807
+ description: 'Returns a substring of a string by code point index, starting at a specified index for a specified number of code points.',
808
+ snippet: '{ $substrCP: ["${1:\\$string}", ${2:start}, ${3:length}] }',
809
+ },
810
+ {
811
+ value: '$toLower',
812
+ meta: metaTags_1.META_EXPR_STRING,
813
+ description: 'Converts a string to lowercase and returns the result.',
814
+ snippet: '{ $toLower: "${1:\\$string}" }',
815
+ },
816
+ {
817
+ value: '$toString',
818
+ meta: metaTags_1.META_EXPR_STRING,
819
+ description: 'The $toString operator converts an expression into a String',
820
+ snippet: '{ $toString: "${1:\\$string}" }',
821
+ link: 'https://learn.microsoft.com/en-us/azure/documentdb/operators/aggregation/type-expression/$tostring', // inferred from another category
822
+ },
823
+ {
824
+ value: '$trim',
825
+ meta: metaTags_1.META_EXPR_STRING,
826
+ description: 'Removes whitespace or specified characters from both ends of a string.',
827
+ snippet: '{ $trim: { input: "${1:\\$string}" } }',
828
+ },
829
+ {
830
+ value: '$toUpper',
831
+ meta: metaTags_1.META_EXPR_STRING,
832
+ description: 'Converts a string to uppercase and returns the result.',
833
+ snippet: '{ $toUpper: "${1:\\$string}" }',
834
+ },
835
+ ];
836
+ // ---------------------------------------------------------------------------
837
+ // Timestamp Expression Operators
838
+ // ---------------------------------------------------------------------------
839
+ const timestampExpressionOperators = [
840
+ {
841
+ value: '$tsIncrement',
842
+ meta: metaTags_1.META_EXPR_TIMESTAMP,
843
+ description: 'The $tsIncrement operator extracts the increment portion from a timestamp value.',
844
+ snippet: '{ $tsIncrement: "${1:\\$timestampField}" }',
845
+ link: (0, docLinks_1.getDocLink)('$tsIncrement', metaTags_1.META_EXPR_TIMESTAMP),
846
+ },
847
+ {
848
+ value: '$tsSecond',
849
+ meta: metaTags_1.META_EXPR_TIMESTAMP,
850
+ description: 'The $tsSecond operator extracts the seconds portion from a timestamp value.',
851
+ snippet: '{ $tsSecond: "${1:\\$timestampField}" }',
852
+ link: (0, docLinks_1.getDocLink)('$tsSecond', metaTags_1.META_EXPR_TIMESTAMP),
853
+ },
854
+ ];
855
+ // ---------------------------------------------------------------------------
856
+ // Trigonometry Expression Operators
857
+ // ---------------------------------------------------------------------------
858
+ const trigonometryExpressionOperators = [
859
+ {
860
+ value: '$sin',
861
+ meta: metaTags_1.META_EXPR_TRIG,
862
+ description: 'Returns the sine of a value measured in radians.',
863
+ snippet: '{ $sin: "${1:\\$value}" }',
864
+ },
865
+ {
866
+ value: '$cos',
867
+ meta: metaTags_1.META_EXPR_TRIG,
868
+ description: 'Returns the cosine of a value measured in radians.',
869
+ snippet: '{ $cos: "${1:\\$value}" }',
870
+ },
871
+ {
872
+ value: '$tan',
873
+ meta: metaTags_1.META_EXPR_TRIG,
874
+ description: 'Returns the tangent of a value measured in radians.',
875
+ snippet: '{ $tan: "${1:\\$value}" }',
876
+ },
877
+ {
878
+ value: '$asin',
879
+ meta: metaTags_1.META_EXPR_TRIG,
880
+ description: 'Returns the arcsine (inverse sine) of a value in radians.',
881
+ snippet: '{ $asin: "${1:\\$value}" }',
882
+ },
883
+ {
884
+ value: '$acos',
885
+ meta: metaTags_1.META_EXPR_TRIG,
886
+ description: 'Returns the arccosine (inverse cosine) of a value in radians.',
887
+ snippet: '{ $acos: "${1:\\$value}" }',
888
+ },
889
+ {
890
+ value: '$atan',
891
+ meta: metaTags_1.META_EXPR_TRIG,
892
+ description: 'Returns the arctangent (inverse tangent) of a value in radians.',
893
+ snippet: '{ $atan: "${1:\\$value}" }',
894
+ },
895
+ {
896
+ value: '$atan2',
897
+ meta: metaTags_1.META_EXPR_TRIG,
898
+ description: 'Returns the arctangent of the quotient of two values, using the signs to determine the quadrant.',
899
+ snippet: '{ $atan2: "${1:\\$value}" }',
900
+ },
901
+ {
902
+ value: '$asinh',
903
+ meta: metaTags_1.META_EXPR_TRIG,
904
+ description: 'Returns the inverse hyperbolic sine of a value.',
905
+ snippet: '{ $asinh: "${1:\\$value}" }',
906
+ },
907
+ {
908
+ value: '$acosh',
909
+ meta: metaTags_1.META_EXPR_TRIG,
910
+ description: 'Returns the inverse hyperbolic cosine of a value.',
911
+ snippet: '{ $acosh: "${1:\\$value}" }',
912
+ },
913
+ {
914
+ value: '$atanh',
915
+ meta: metaTags_1.META_EXPR_TRIG,
916
+ description: 'Returns the inverse hyperbolic tangent of a value.',
917
+ snippet: '{ $atanh: "${1:\\$value}" }',
918
+ },
919
+ {
920
+ value: '$sinh',
921
+ meta: metaTags_1.META_EXPR_TRIG,
922
+ description: 'Returns the hyperbolic sine of a value.',
923
+ snippet: '{ $sinh: "${1:\\$value}" }',
924
+ },
925
+ {
926
+ value: '$cosh',
927
+ meta: metaTags_1.META_EXPR_TRIG,
928
+ description: 'Returns the hyperbolic cosine of a value.',
929
+ snippet: '{ $cosh: "${1:\\$value}" }',
930
+ },
931
+ {
932
+ value: '$tanh',
933
+ meta: metaTags_1.META_EXPR_TRIG,
934
+ description: 'Returns the hyperbolic tangent of a value.',
935
+ snippet: '{ $tanh: "${1:\\$value}" }',
936
+ },
937
+ {
938
+ value: '$degreesToRadians',
939
+ meta: metaTags_1.META_EXPR_TRIG,
940
+ description: 'Converts a value from degrees to radians.',
941
+ snippet: '{ $degreesToRadians: "${1:\\$angle}" }',
942
+ },
943
+ {
944
+ value: '$radiansToDegrees',
945
+ meta: metaTags_1.META_EXPR_TRIG,
946
+ description: 'Converts a value from radians to degrees.',
947
+ snippet: '{ $radiansToDegrees: "${1:\\$angle}" }',
948
+ },
949
+ ];
950
+ // ---------------------------------------------------------------------------
951
+ // Type Expression Operators
952
+ // ---------------------------------------------------------------------------
953
+ const typeExpressionOperators = [
954
+ {
955
+ value: '$convert',
956
+ meta: metaTags_1.META_EXPR_TYPE,
957
+ description: 'The $convert operator converts an expression into the specified type',
958
+ snippet: '{ $convert: { input: "${1:\\$field}", to: "${2:type}" } }',
959
+ link: (0, docLinks_1.getDocLink)('$convert', metaTags_1.META_EXPR_TYPE),
960
+ },
961
+ {
962
+ value: '$isNumber',
963
+ meta: metaTags_1.META_EXPR_TYPE,
964
+ description: 'The $isNumber operator checks if a specified expression is a numerical type',
965
+ snippet: '{ $isNumber: "${1:\\$field}" }',
966
+ link: (0, docLinks_1.getDocLink)('$isNumber', metaTags_1.META_EXPR_TYPE),
967
+ },
968
+ {
969
+ value: '$toBool',
970
+ meta: metaTags_1.META_EXPR_TYPE,
971
+ description: 'The $toBool operator converts an expression into a Boolean type',
972
+ snippet: '{ $toBool: "${1:\\$field}" }',
973
+ link: (0, docLinks_1.getDocLink)('$toBool', metaTags_1.META_EXPR_TYPE),
974
+ },
975
+ {
976
+ value: '$toDate',
977
+ meta: metaTags_1.META_EXPR_TYPE,
978
+ description: 'The $toDate operator converts supported types to a proper Date object.',
979
+ snippet: '{ $toDate: "${1:\\$field}" }',
980
+ link: (0, docLinks_1.getDocLink)('$toDate', metaTags_1.META_EXPR_TYPE),
981
+ },
982
+ {
983
+ value: '$toDecimal',
984
+ meta: metaTags_1.META_EXPR_TYPE,
985
+ description: 'The $toDecimal operator converts an expression into a Decimal type',
986
+ snippet: '{ $toDecimal: "${1:\\$field}" }',
987
+ link: (0, docLinks_1.getDocLink)('$toDecimal', metaTags_1.META_EXPR_TYPE),
988
+ },
989
+ {
990
+ value: '$toDouble',
991
+ meta: metaTags_1.META_EXPR_TYPE,
992
+ description: 'The $toDouble operator converts an expression into a Double value',
993
+ snippet: '{ $toDouble: "${1:\\$field}" }',
994
+ link: (0, docLinks_1.getDocLink)('$toDouble', metaTags_1.META_EXPR_TYPE),
995
+ },
996
+ {
997
+ value: '$toInt',
998
+ meta: metaTags_1.META_EXPR_TYPE,
999
+ description: 'The $toInt operator converts an expression into an Integer',
1000
+ snippet: '{ $toInt: "${1:\\$field}" }',
1001
+ link: (0, docLinks_1.getDocLink)('$toInt', metaTags_1.META_EXPR_TYPE),
1002
+ },
1003
+ {
1004
+ value: '$toLong',
1005
+ meta: metaTags_1.META_EXPR_TYPE,
1006
+ description: 'The $toLong operator converts an expression into a Long value',
1007
+ snippet: '{ $toLong: "${1:\\$field}" }',
1008
+ link: (0, docLinks_1.getDocLink)('$toLong', metaTags_1.META_EXPR_TYPE),
1009
+ },
1010
+ {
1011
+ value: '$toObjectId',
1012
+ meta: metaTags_1.META_EXPR_TYPE,
1013
+ description: 'The $toObjectId operator converts an expression into an ObjectId',
1014
+ snippet: '{ $toObjectId: "${1:\\$field}" }',
1015
+ link: (0, docLinks_1.getDocLink)('$toObjectId', metaTags_1.META_EXPR_TYPE),
1016
+ },
1017
+ {
1018
+ value: '$toString',
1019
+ meta: metaTags_1.META_EXPR_TYPE,
1020
+ description: 'The $toString operator converts an expression into a String',
1021
+ snippet: '{ $toString: "${1:\\$field}" }',
1022
+ link: (0, docLinks_1.getDocLink)('$toString', metaTags_1.META_EXPR_TYPE),
1023
+ },
1024
+ {
1025
+ value: '$type',
1026
+ meta: metaTags_1.META_EXPR_TYPE,
1027
+ description: 'The $type operator retrieves documents if the chosen field is of the specified type.',
1028
+ snippet: '{ $type: "${1:\\$field}" }',
1029
+ link: 'https://learn.microsoft.com/en-us/azure/documentdb/operators/element-query/$type', // inferred from another category
1030
+ },
1031
+ ];
1032
+ // ---------------------------------------------------------------------------
1033
+ // Variable Expression Operators
1034
+ // ---------------------------------------------------------------------------
1035
+ const variableExpressionOperators = [
1036
+ {
1037
+ value: '$let',
1038
+ meta: metaTags_1.META_EXPR_VARIABLE,
1039
+ description: 'The $let operator allows defining variables for use in a specified expression, enabling complex calculations and reducing code repetition.',
1040
+ snippet: '{ $let: { vars: { ${1:var}: ${2:expression} }, in: ${3:expression} } }',
1041
+ link: (0, docLinks_1.getDocLink)('$let', metaTags_1.META_EXPR_VARIABLE),
1042
+ },
1043
+ ];
1044
+ // ---------------------------------------------------------------------------
1045
+ // Conditional Expression Operators
1046
+ // ---------------------------------------------------------------------------
1047
+ const conditionalExpressionOperators = [
1048
+ {
1049
+ value: '$cond',
1050
+ meta: metaTags_1.META_EXPR_CONDITIONAL,
1051
+ description: 'The $cond operator is used to evaluate a condition and return one of two expressions based on the result.',
1052
+ snippet: '{ $cond: { if: { ${1:expression} }, then: ${2:trueValue}, else: ${3:falseValue} } }',
1053
+ link: (0, docLinks_1.getDocLink)('$cond', metaTags_1.META_EXPR_CONDITIONAL),
1054
+ },
1055
+ {
1056
+ value: '$ifNull',
1057
+ meta: metaTags_1.META_EXPR_CONDITIONAL,
1058
+ description: 'The $ifNull operator is used to evaluate an expression and return a specified value if the expression resolves to null.',
1059
+ snippet: '{ $ifNull: ["${1:\\$field}", ${2:replacement}] }',
1060
+ link: (0, docLinks_1.getDocLink)('$ifNull', metaTags_1.META_EXPR_CONDITIONAL),
1061
+ },
1062
+ {
1063
+ value: '$switch',
1064
+ meta: metaTags_1.META_EXPR_CONDITIONAL,
1065
+ description: 'The $switch operator is used to evaluate a series of conditions and return a value based on the first condition that evaluates to true.',
1066
+ snippet: '{ $switch: { branches: [{ case: { ${1:expression} }, then: ${2:value} }], default: ${3:defaultValue} } }',
1067
+ link: (0, docLinks_1.getDocLink)('$switch', metaTags_1.META_EXPR_CONDITIONAL),
1068
+ },
1069
+ ];
1070
+ // ---------------------------------------------------------------------------
1071
+ // Registration
1072
+ // ---------------------------------------------------------------------------
1073
+ function loadExpressionOperators() {
1074
+ (0, getFilteredCompletions_1.registerOperators)([
1075
+ ...arithmeticExpressionOperators,
1076
+ ...arrayExpressionOperators,
1077
+ ...bitwiseOperators,
1078
+ ...booleanExpressionOperators,
1079
+ ...comparisonExpressionOperators,
1080
+ ...dataSizeOperators,
1081
+ ...dateExpressionOperators,
1082
+ ...literalExpressionOperator,
1083
+ ...miscellaneousOperators,
1084
+ ...objectExpressionOperators,
1085
+ ...setExpressionOperators,
1086
+ ...stringExpressionOperators,
1087
+ ...timestampExpressionOperators,
1088
+ ...trigonometryExpressionOperators,
1089
+ ...typeExpressionOperators,
1090
+ ...variableExpressionOperators,
1091
+ ...conditionalExpressionOperators,
1092
+ ]);
1093
+ }
1094
+ //# sourceMappingURL=expressionOperators.js.map