UNPKG

113 kBTypeScriptView Raw
1declare module 'mongoose' {
2
3 /**
4 * [Expressions reference](https://www.mongodb.com/docs/manual/meta/aggregation-quick-reference/#expressions)
5 */
6 type AggregationVariables =
7 SpecialPathVariables |
8 '$$NOW' |
9 '$$CLUSTER_TIME' |
10 '$$DESCEND' |
11 '$$PRUNE' |
12 '$$KEEP';
13
14 type SpecialPathVariables =
15 '$$ROOT' |
16 '$$CURRENT' |
17 '$$REMOVE';
18
19 export namespace Expression {
20 export interface Abs {
21 /**
22 * Returns the absolute value of a number.
23 *
24 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/abs/#mongodb-expression-exp.-abs
25 */
26 $abs: Path | ArithmeticExpressionOperator;
27 }
28
29 export interface Add {
30 /**
31 * Adds numbers to return the sum, or adds numbers and a date to return a new date. If adding numbers and a date, treats the numbers as milliseconds. Accepts any number of argument expressions, but at most, one expression can resolve to a date.
32 *
33 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/add/#mongodb-expression-exp.-add
34 */
35 $add: Expression[];
36 }
37
38 export interface Ceil {
39 /**
40 * Returns the smallest integer greater than or equal to the specified number.
41 *
42 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/ceil/#mongodb-expression-exp.-ceil
43 */
44 $ceil: NumberExpression;
45 }
46
47 export interface Divide {
48 /**
49 * Returns the result of dividing the first number by the second. Accepts two argument expressions.
50 *
51 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/divide/#mongodb-expression-exp.-divide
52 */
53 $divide: NumberExpression[];
54 }
55
56 export interface Exp {
57 /**
58 * Raises e to the specified exponent.
59 *
60 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/exp/#mongodb-expression-exp.-exp
61 */
62 $exp: NumberExpression;
63 }
64
65 export interface Floor {
66 /**
67 * Returns the largest integer less than or equal to the specified number.
68 *
69 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/floor/#mongodb-expression-exp.-floor
70 */
71 $floor: NumberExpression;
72 }
73
74 export interface Ln {
75 /**
76 * Calculates the natural log of a number.
77 *
78 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/ln/#mongodb-expression-exp.-ln
79 */
80 $ln: NumberExpression;
81 }
82
83 export interface Log {
84 /**
85 * Calculates the log of a number in the specified base.
86 *
87 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/log/#mongodb-expression-exp.-log
88 */
89 $log: [NumberExpression, NumberExpression];
90 }
91
92 export interface Log10 {
93 /**
94 * Calculates the log base 10 of a number.
95 *
96 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/log10/#mongodb-expression-exp.-log10
97 */
98 $log10: NumberExpression;
99 }
100
101 export interface Mod {
102 /**
103 * Returns the remainder of the first number divided by the second. Accepts two argument expressions.
104 *
105 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/mod/#mongodb-expression-exp.-mod
106 */
107 $mod: [NumberExpression, NumberExpression];
108 }
109 export interface Multiply {
110 /**
111 * Multiplies numbers to return the product. Accepts any number of argument expressions.
112 *
113 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/multiply/#mongodb-expression-exp.-multiply
114 */
115 $multiply: NumberExpression[];
116 }
117
118 export interface Pow {
119 /**
120 * Raises a number to the specified exponent.
121 *
122 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/pow/#mongodb-expression-exp.-pow
123 */
124 $pow: [NumberExpression, NumberExpression];
125 }
126
127 export interface Round {
128 /**
129 * Rounds a number to to a whole integer or to a specified decimal place.
130 *
131 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/round/#mongodb-expression-exp.-round
132 */
133 $round: [NumberExpression, NumberExpression?];
134 }
135
136 export interface Sqrt {
137 /**
138 * Calculates the square root.
139 *
140 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/sqrt/#mongodb-expression-exp.-sqrt
141 */
142 $sqrt: NumberExpression;
143 }
144
145 export interface Subtract {
146 /**
147 * Returns the result of subtracting the second value from the first. If the two values are numbers, return the difference. If the two values are dates, return the difference in milliseconds. If the two values are a date and a number in milliseconds, return the resulting date. Accepts two argument expressions. If the two values are a date and a number, specify the date argument first as it is not meaningful to subtract a date from a number.
148 *
149 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/subtract/#mongodb-expression-exp.-subtract
150 */
151 $subtract: (NumberExpression | DateExpression)[];
152 }
153
154 export interface Trunc {
155 /**
156 * Truncates a number to a whole integer or to a specified decimal place.
157 *
158 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/trunc/#mongodb-expression-exp.-trunc
159 */
160 $trunc: [NumberExpression, NumberExpression?];
161 }
162
163 export interface Sin {
164 /**
165 * Returns the sine of a value that is measured in radians.
166 *
167 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/sin/#mongodb-expression-exp.-sin
168 */
169 $sin: NumberExpression;
170 }
171
172 export interface Cos {
173 /**
174 * Returns the cosine of a value that is measured in radians.
175 *
176 * @version 4.2
177 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/cos/#mongodb-expression-exp.-cos
178 */
179 $cos: NumberExpression;
180 }
181
182 export interface Tan {
183 /**
184 * Returns the tangent of a value that is measured in radians.
185 *
186 * @version 4.2
187 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/tan/#mongodb-expression-exp.-tan
188 */
189 $tan: NumberExpression;
190 }
191
192 export interface Asin {
193 /**
194 * Returns the inverse sin (arc sine) of a value in radians.
195 *
196 * @version 4.2
197 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/asin/#mongodb-expression-exp.-asin
198 */
199 $asin: NumberExpression;
200 }
201
202 export interface Acos {
203 /**
204 * Returns the inverse cosine (arc cosine) of a value in radians.
205 *
206 * @version 4.2
207 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/acos/#mongodb-expression-exp.-acos
208 */
209 $acos: NumberExpression;
210 }
211
212 export interface Atan {
213 /**
214 * Returns the inverse tangent (arc tangent) of a value in radians.
215 *
216 * @version 4.2
217 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/atan/#mongodb-expression-exp.-atan
218 */
219 $atan: NumberExpression;
220 }
221
222 export interface Atan2 {
223 /**
224 * Returns the inverse tangent (arc tangent) of y / x in radians, where y and x are the first and second values passed to the expression respectively.
225 *
226 * @version 4.2
227 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/atan2/#mongodb-expression-exp.-atan2
228 */
229 $atan2: NumberExpression;
230 }
231
232 export interface Asinh {
233 /**
234 * Returns the inverse hyperbolic sine (hyperbolic arc sine) of a value in radians.
235 *
236 * @version 4.2
237 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/asinh/#mongodb-expression-exp.-asinh
238 */
239 $asinh: NumberExpression;
240 }
241
242 export interface Acosh {
243 /**
244 * Returns the inverse hyperbolic cosine (hyperbolic arc cosine) of a value in radians.
245 *
246 * @version 4.2
247 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/acosh/#mongodb-expression-exp.-acosh
248 */
249 $acosh: NumberExpression;
250 }
251
252 export interface Atanh {
253
254 /**
255 * Returns the inverse hyperbolic tangent (hyperbolic arc tangent) of a value in radians.
256 *
257 * @version 4.2
258 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/atanh/#mongodb-expression-exp.-atanh
259 */
260 $atanh: NumberExpression;
261 }
262
263 export interface Sinh {
264 /**
265 * Returns the hyperbolic sine of a value that is measured in radians.
266 *
267 * @version 4.2
268 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/sinh/#mongodb-expression-exp.-sinh
269 */
270 $sinh: NumberExpression;
271 }
272
273 export interface Cosh {
274 /**
275 * Returns the hyperbolic cosine of a value that is measured in radians.
276 *
277 * @version 4.2
278 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/cosh/#mongodb-expression-exp.-cosh
279 */
280 $cosh: NumberExpression;
281 }
282
283 export interface Tanh {
284 /**
285 * Returns the hyperbolic tangent of a value that is measured in radians.
286 *
287 * @version 4.2
288 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/tanh/#mongodb-expression-exp.-tanh
289 */
290 $tanh: NumberExpression;
291 }
292
293 export interface DegreesToRadians {
294 /**
295 * Converts a value from degrees to radians.
296 *
297 * @version 4.2
298 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/degreesToRadians/#mongodb-expression-exp.-degreesToRadians
299 */
300 $degreesToRadians: NumberExpression;
301 }
302
303 export interface RadiansToDegrees {
304 /**
305 * Converts a value from radians to degrees.
306 *
307 * @version 4.2
308 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/radiansToDegrees/#mongodb-expression-exp.-radiansToDegrees
309 */
310 $radiansToDegrees: NumberExpression;
311 }
312
313 export interface Meta {
314 /**
315 * Access available per-document metadata related to the aggregation operation.
316 *
317 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/meta/#mongodb-expression-exp.-meta
318 */
319 $meta: 'textScore' | 'indexKey';
320 }
321
322 export interface DateAdd {
323 /**
324 * Adds a number of time units to a date object.
325 *
326 * @version 5.0.0
327 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateAdd/#mongodb-expression-exp.-dateAdd
328 */
329 $dateAdd: {
330 /**
331 * The beginning date, in UTC, for the addition operation. The startDate can be any expression that resolves to a Date, a Timestamp, or an ObjectID.
332 */
333 startDate: DateExpression;
334 /**
335 * The unit used to measure the amount of time added to the startDate. The unit is an expression that resolves to one of the following strings:
336 * - year
337 * - quarter
338 * - week
339 * - month
340 * - day
341 * - hour
342 * - minute
343 * - second
344 * - millisecond
345 */
346 unit: StringExpression<DateUnit>;
347 /**
348 * The number of units added to the startDate. The amount is an expression that resolves to an integer or long. The amount can also resolve to an integral decimal or a double if that value can be converted to a long without loss of precision.
349 */
350 amount: NumberExpression;
351 /**
352 * The timezone to carry out the operation. <tzExpression> must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC.
353 */
354 timezone?: tzExpression;
355 };
356 }
357
358 export interface DateDiff {
359 /**
360 * Returns the difference between two dates.
361 *
362 * @version 5.0
363 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateDiff/#mongodb-expression-exp.-dateDiff
364 */
365 $dateDiff: {
366 /**
367 * The start of the time period. The startDate can be any expression that resolves to a Date, a Timestamp, or an ObjectID.
368 */
369 startDate: DateExpression;
370 /**
371 * The end of the time period. The endDate can be any expression that resolves to a Date, a Timestamp, or an ObjectID.
372 */
373 endDate: DateExpression;
374 /**
375 * The time measurement unit between the startDate and endDate. It is an expression that resolves to a string:
376 * - year
377 * - quarter
378 * - week
379 * - month
380 * - day
381 * - hour
382 * - minute
383 * - second
384 * - millisecond
385 */
386 unit: StringExpression<DateUnit>;
387 /**
388 * The timezone to carry out the operation. <tzExpression> must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC.
389 */
390 timezone?: tzExpression;
391 /**
392 * Used when the unit is equal to week. Defaults to Sunday. The startOfWeek parameter is an expression that resolves to a case insensitive string:
393 * - monday (or mon)
394 * - tuesday (or tue)
395 * - wednesday (or wed)
396 * - thursday (or thu)
397 * - friday (or fri)
398 * - saturday (or sat)
399 * - sunday (or sun)
400 */
401 startOfWeek?: StringExpression<StartOfWeek>;
402 }
403 }
404
405 // TODO: Can be done better
406 export interface DateFromParts {
407 /**
408 * Constructs a BSON Date object given the date's constituent parts.
409 *
410 * @version 3.6
411 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateFromParts/#mongodb-expression-exp.-dateFromParts
412 */
413 $dateFromParts: {
414 /**
415 * ISO Week Date Year. Can be any expression that evaluates to a number.
416 *
417 * Value range: 1-9999
418 *
419 * If the number specified is outside this range, $dateFromParts errors. Starting in MongoDB 4.4, the lower bound for this value is 1. In previous versions of MongoDB, the lower bound was 0.
420 */
421 isoWeekYear?: NumberExpression;
422 /**
423 * Week of year. Can be any expression that evaluates to a number.
424 *
425 * Defaults to 1.
426 *
427 * Value range: 1-53
428 *
429 * Starting in MongoDB 4.0, if the number specified is outside this range, $dateFromParts incorporates the difference in the date calculation. See Value Range for examples.
430 */
431 isoWeek?: NumberExpression;
432 /**
433 * Day of week (Monday 1 - Sunday 7). Can be any expression that evaluates to a number.
434 *
435 * Defaults to 1.
436 *
437 * Value range: 1-7
438 *
439 * Starting in MongoDB 4.0, if the number specified is outside this range, $dateFromParts incorporates the difference in the date calculation. See Value Range for examples.
440 */
441 isoDayOfWeek?: NumberExpression;
442 /**
443 * Calendar year. Can be any expression that evaluates to a number.
444 *
445 * Value range: 1-9999
446 *
447 * If the number specified is outside this range, $dateFromParts errors. Starting in MongoDB 4.4, the lower bound for this value is 1. In previous versions of MongoDB, the lower bound was 0.
448 */
449 year?: NumberExpression;
450 /**
451 * Month. Can be any expression that evaluates to a number.
452 *
453 * Defaults to 1.
454 *
455 * Value range: 1-12
456 *
457 * Starting in MongoDB 4.0, if the number specified is outside this range, $dateFromParts incorporates the difference in the date calculation. See Value Range for examples.
458 */
459 month?: NumberExpression;
460 /**
461 * Day of month. Can be any expression that evaluates to a number.
462 *
463 * Defaults to 1.
464 *
465 * Value range: 1-31
466 *
467 * Starting in MongoDB 4.0, if the number specified is outside this range, $dateFromParts incorporates the difference in the date calculation. See Value Range for examples.
468 */
469 day?: NumberExpression;
470 /**
471 * Hour. Can be any expression that evaluates to a number.
472 *
473 * Defaults to 0.
474 *
475 * Value range: 0-23
476 *
477 * Starting in MongoDB 4.0, if the number specified is outside this range, $dateFromParts incorporates the difference in the date calculation. See Value Range for examples.
478 */
479 hour?: NumberExpression;
480 /**
481 * Minute. Can be any expression that evaluates to a number.
482 *
483 * Defaults to 0.
484 *
485 * Value range: 0-59 Starting in MongoDB 4.0, if the number specified is outside this range, $dateFromParts incorporates the difference in the date calculation. See Value Range for examples.
486 */
487 minute?: NumberExpression;
488 /**
489 * Second. Can be any expression that evaluates to a number.
490 *
491 * Defaults to 0.
492 *
493 * Value range: 0-59
494 *
495 * Starting in MongoDB 4.0, if the number specified is outside this range, $dateFromParts incorporates the difference in the date calculation. See Value Range for examples.
496 */
497 second?: NumberExpression;
498 /**
499 * Millisecond. Can be any expression that evaluates to a number.
500 *
501 * Defaults to 0.
502 *
503 * Value range: 0-999
504 *
505 * Starting in MongoDB 4.0, if the number specified is outside this range, $dateFromParts incorporates the difference in the date calculation. See Value Range for examples.
506 */
507 millisecond?: NumberExpression;
508 /**
509 * The timezone to carry out the operation. <tzExpression> must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC.
510 */
511 timezone?: tzExpression;
512 };
513 }
514
515 export interface DateFromString {
516 /**
517 * Converts a date/time string to a date object.
518 *
519 * @version 3.6
520 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateFromString/#mongodb-expression-exp.-dateFromString
521 */
522 $dateFromString: {
523 dateString: StringExpression<string>;
524 /**
525 * The date format specification of the dateString. The format can be any expression that evaluates to a string literal, containing 0 or more format specifiers. For a list of specifiers available, see Format Specifiers.
526 *
527 * If unspecified, $dateFromString uses "%Y-%m-%dT%H:%M:%S.%LZ" as the default format.
528 * @version 4.0
529 */
530 format?: FormatString;
531 /**
532 * The time zone to use to format the date.
533 *
534 * Note: If the dateString argument is formatted like '2017-02-08T12:10:40.787Z', in which the 'Z' at the end indicates Zulu time (UTC time zone), you cannot specify the timezone argument.
535 */
536 timezone?: tzExpression;
537 /**
538 * Optional. If $dateFromString encounters an error while parsing the given dateString, it outputs the result value of the provided onError expression. This result value can be of any type.
539 *
540 * If you do not specify onError, $dateFromString throws an error if it cannot parse dateString.
541 */
542 onError?: Expression;
543 /**
544 * Optional. If the dateString provided to $dateFromString is null or missing, it outputs the result value of the provided onNull expression. This result value can be of any type.
545 *
546 * If you do not specify onNull and dateString is null or missing, then $dateFromString outputs null.
547 */
548 onNull?: Expression;
549 };
550 }
551
552 export interface DateSubtract {
553 /**
554 * Subtracts a number of time units from a date object.
555 *
556 * @version 5.0
557 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateSubtract/#mongodb-expression-exp.-dateSubtract
558 */
559 $dateSubtract: {
560 /**
561 * The beginning date, in UTC, for the subtraction operation. The startDate can be any expression that resolves to a Date, a Timestamp, or an ObjectID.
562 */
563 startDate: DateExpression;
564 /**
565 * The unit of time, specified as an expression that must resolve to one of these strings:
566 * - year
567 * - quarter
568 * - week
569 * - month
570 * - day
571 * - hour
572 * - minute
573 * - second
574 * - millisecond
575 *
576 * Together, binSize and unit specify the time period used in the $dateTrunc calculation.
577 */
578 unit: StringExpression<DateUnit>;
579 /**
580 * The number of units subtracted from the startDate. The amount is an expression that resolves to an integer or long. The amount can also resolve to an integral decimal and or a double if that value can be converted to a long without loss of precision.
581 */
582 amount: NumberExpression;
583 /**
584 * The timezone to carry out the operation. <tzExpression> must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC.
585 */
586 timezone?: tzExpression;
587 };
588 }
589
590 export interface DateToParts {
591 /**
592 * Returns a document containing the constituent parts of a date.
593 *
594 * @version 3.6
595 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateToParts/#mongodb-expression-exp.-dateToParts
596 */
597 $dateToParts: {
598 /**
599 * The input date for which to return parts. <dateExpression> can be any expression that resolves to a Date, a Timestamp, or an ObjectID. For more information on expressions, see Expressions.
600 */
601 date: DateExpression;
602 /**
603 * The timezone of the operation result. <tzExpression> must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC.
604 *
605 * @version 3.6
606 */
607 timezone?: tzExpression;
608 /**
609 * If set to true, modifies the output document to use ISO week date fields. Defaults to false.
610 */
611 iso8601?: boolean;
612 };
613 }
614
615 export interface DateToString {
616 /**
617 * Returns the date as a formatted string.
618 *
619 * @version 3.6
620 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateToString/#mongodb-expression-exp.-dateToString
621 */
622 $dateToString: {
623 /**
624 * The date to convert to string. <dateExpression> must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID.
625 */
626 date: DateExpression;
627 /**
628 * The date format specification. <formatString> can be any string literal, containing 0 or more format specifiers. For a list of specifiers available, see Format Specifiers.
629 *
630 * If unspecified, $dateToString uses "%Y-%m-%dT%H:%M:%S.%LZ" as the default format.
631 *
632 * Changed in version 4.0: The format field is optional if featureCompatibilityVersion (fCV) is set to "4.0" or greater. For more information on fCV, see setFeatureCompatibilityVersion.
633 */
634 format?: FormatString;
635 /**
636 * The timezone of the operation result. <tzExpression> must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC.
637 *
638 * @version 3.6
639 */
640 timezone?: tzExpression;
641 /**
642 * The value to return if the date is null or missing. The arguments can be any valid expression.
643 *
644 * If unspecified, $dateToString returns null if the date is null or missing.
645 *
646 * Changed in version 4.0: Requires featureCompatibilityVersion (fCV) set to "4.0" or greater. For more information on fCV, see setFeatureCompatibilityVersion.
647 */
648 onNull?: Expression;
649 };
650 }
651
652 export interface DateTrunc {
653 /**
654 * Truncates a date.
655 *
656 * @version 5.0
657 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateTrunc/#mongodb-expression-exp.-dateTrunc
658 */
659 $dateTrunc: {
660 /**
661 * The date to truncate, specified in UTC. The date can be any expression that resolves to a Date, a Timestamp, or an ObjectID.
662 */
663 date: DateExpression;
664 /**
665 * The unit of time, specified as an expression that must resolve to one of these strings:
666 * - year
667 * - quarter
668 * - week
669 * - month
670 * - day
671 * - hour
672 * - minute
673 * - second
674 * - millisecond
675 *
676 * Together, binSize and unit specify the time period used in the $dateTrunc calculation.
677 */
678 unit: StringExpression<DateUnit>;
679 /**
680 * The numeric time value, specified as an expression that must resolve to a positive non-zero number. Defaults to 1.
681 *
682 * Together, binSize and unit specify the time period used in the $dateTrunc calculation.
683 */
684 binSize?: NumberExpression;
685 /**
686 * The timezone of the operation result. <tzExpression> must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC.
687 */
688 timezone?: tzExpression;
689 /**
690 * Used when the unit is equal to week. Defaults to Sunday. The startOfWeek parameter is an expression that resolves to a case insensitive string:
691 * - monday (or mon)
692 * - tuesday (or tue)
693 * - wednesday (or wed)
694 * - thursday (or thu)
695 * - friday (or fri)
696 * - saturday (or sat)
697 * - sunday (or sun)
698 */
699 startOfWeek?: StringExpression<StartOfWeek>;
700 }
701 }
702
703 export interface DayOfMonth {
704 /**
705 * Returns the day of the month for a date as a number between 1 and 31.
706 *
707 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfMonth/#mongodb-expression-exp.-dayOfMonth
708 */
709 $dayOfMonth: DateExpression | {
710 /**
711 * The date to which the operator is applied. <dateExpression> must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID.
712 */
713 date: DateExpression;
714 /**
715 * The timezone of the operation result. <tzExpression> must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC.
716 */
717 timezone?: tzExpression;
718 };
719 }
720
721 export interface DayOfWeek {
722 /**
723 * Returns the day of the week for a date as a number between 1 (Sunday) and 7 (Saturday).
724 *
725 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfWeek/#mongodb-expression-exp.-dayOfWeek
726 */
727 $dayOfWeek: DateExpression | {
728 /**
729 * The date to which the operator is applied. <dateExpression> must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID.
730 */
731 date: DateExpression;
732 /**
733 * The timezone of the operation result. <tzExpression> must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC.
734 */
735 timezone?: tzExpression;
736 };
737 }
738
739 export interface DayOfYear {
740 /**
741 * Returns the day of the year for a date as a number between 1 and 366 (leap year).
742 *
743 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfYear/#mongodb-expression-exp.-dayOfYear
744 */
745 $dayOfYear: DateExpression | {
746 /**
747 * The date to which the operator is applied. <dateExpression> must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID.
748 */
749 date: DateExpression;
750 /**
751 * The timezone of the operation result. <tzExpression> must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC.
752 */
753 timezone?: tzExpression;
754 };
755 }
756
757 export interface Hour {
758 /**
759 * Returns the hour for a date as a number between 0 and 23.
760 *
761 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/hour/#mongodb-expression-exp.-hour
762 */
763 $hour: DateExpression | {
764 /**
765 * The date to which the operator is applied. <dateExpression> must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID.
766 */
767 date: DateExpression;
768 /**
769 * The timezone of the operation result. <tzExpression> must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC.
770 */
771 timezone?: tzExpression;
772 };
773 }
774
775 export interface IsoDayOfWeek {
776 /**
777 * Returns the weekday number in ISO 8601 format, ranging from 1 (for Monday) to 7 (for Sunday).
778 *
779 * @version 3.4
780 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoDayOfWeek/#mongodb-expression-exp.-isoDayOfWeek
781 */
782 $isoDayOfWeek: DateExpression | {
783 /**
784 * The date to which the operator is applied. <dateExpression> must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID.
785 */
786 date: DateExpression;
787 /**
788 * The timezone of the operation result. <tzExpression> must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC.
789 */
790 timezone?: tzExpression;
791 };
792 }
793
794 export interface IsoWeek {
795 /**
796 * Returns the week number in ISO 8601 format, ranging from 1 to 53. Week numbers start at 1 with the week (Monday through Sunday) that contains the year's first Thursday.
797 *
798 * @version 3.4
799 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeek/#mongodb-expression-exp.-isoWeek
800 */
801 $isoWeek: DateExpression | {
802 /**
803 * The date to which the operator is applied. <dateExpression> must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID.
804 */
805 date: DateExpression;
806 /**
807 * The timezone of the operation result. <tzExpression> must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC.
808 */
809 timezone?: tzExpression;
810 };
811 }
812
813 export interface IsoWeekYear {
814 /**
815 * Returns the year number in ISO 8601 format. The year starts with the Monday of week 1 (ISO 8601) and ends with the Sunday of the last week (ISO 8601).
816 *
817 * @version 3.4
818 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeekYear/#mongodb-expression-exp.-isoWeekYear
819 */
820 $isoWeekYear: DateExpression | {
821 /**
822 * The date to which the operator is applied. <dateExpression> must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID.
823 */
824 date: DateExpression;
825 /**
826 * The timezone of the operation result. <tzExpression> must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC.
827 */
828 timezone?: tzExpression;
829 };
830 }
831
832 export interface Millisecond {
833 /**
834 * Returns the milliseconds of a date as a number between 0 and 999.
835 *
836 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/millisecond/#mongodb-expression-exp.-millisecond
837 */
838 $millisecond: DateExpression | {
839 /**
840 * The date to which the operator is applied. <dateExpression> must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID.
841 */
842 date: DateExpression;
843 /**
844 * The timezone of the operation result. <tzExpression> must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC.
845 */
846 timezone?: tzExpression;
847 };
848 }
849
850 export interface Minute {
851 /**
852 * Returns the minute for a date as a number between 0 and 59.
853 *
854 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/minute/#mongodb-expression-exp.-minute
855 */
856 $minute: DateExpression | {
857 /**
858 * The date to which the operator is applied. <dateExpression> must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID.
859 */
860 date: DateExpression;
861 /**
862 * The timezone of the operation result. <tzExpression> must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC.
863 */
864 timezone?: tzExpression;
865 };
866 }
867
868 export interface Month {
869 /**
870 * Returns the month for a date as a number between 1 (January) and 12 (December).
871 *
872 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/month/#mongodb-expression-exp.-month
873 */
874 $month: DateExpression | {
875 /**
876 * The date to which the operator is applied. <dateExpression> must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID.
877 */
878 date: DateExpression;
879 /**
880 * The timezone of the operation result. <tzExpression> must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC.
881 */
882 timezone?: tzExpression;
883 };
884 }
885
886 export interface Second {
887 /**
888 * Returns the seconds for a date as a number between 0 and 60 (leap seconds).
889 *
890 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/second/#mongodb-expression-exp.-second
891 */
892 $second: DateExpression | {
893 /**
894 * The date to which the operator is applied. <dateExpression> must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID.
895 */
896 date: DateExpression;
897 /**
898 * The timezone of the operation result. <tzExpression> must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC.
899 */
900 timezone?: tzExpression;
901 };
902 }
903
904 export interface ToDate {
905 /**
906 * Converts value to a Date.
907 *
908 * @version 4.0
909 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toDate/#mongodb-expression-exp.-toDate
910 */
911 $toDate: Expression;
912 }
913
914 export interface Week {
915 /**
916 * Returns the week number for a date as a number between 0 (the partial week that precedes the first Sunday of the year) and 53 (leap year).
917 *
918 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/week/#mongodb-expression-exp.-week
919 */
920 $week: DateExpression | {
921 /**
922 * The date to which the operator is applied. <dateExpression> must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID.
923 */
924 date: DateExpression;
925 /**
926 * The timezone of the operation result. <tzExpression> must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC.
927 */
928 timezone?: tzExpression;
929 };
930 }
931
932 export interface Year {
933 /**
934 * Returns the year for a date as a number (e.g. 2014).
935 *
936 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/year/#mongodb-expression-exp.-year
937 */
938 $year: DateExpression | {
939 /**
940 * The date to which the operator is applied. <dateExpression> must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID.
941 */
942 date: DateExpression;
943 /**
944 * The timezone of the operation result. <tzExpression> must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC.
945 */
946 timezone?: tzExpression;
947 };
948 }
949
950 export interface And {
951 /**
952 * Returns true only when all its expressions evaluate to true. Accepts any number of argument expressions.
953 *
954 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/and/#mongodb-expression-exp.-and
955 */
956 $and: (Expression | Record<string, Expression>)[];
957 }
958
959 export interface Not {
960 /**
961 * Returns the boolean value that is the opposite of its argument expression. Accepts a single argument expression.
962 *
963 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/not/#mongodb-expression-exp.-not
964 */
965 $not: [Expression];
966 }
967
968 export interface Or {
969 /**
970 * Returns true when any of its expressions evaluates to true. Accepts any number of argument expressions.
971 *
972 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/or/#mongodb-expression-exp.-or
973 */
974 $or: (Expression | Record<string, Expression>)[];
975 }
976
977 export interface Cmp {
978 /**
979 * Returns 0 if the two values are equivalent, 1 if the first value is greater than the second, and -1 if the first value is less than the second.
980 *
981 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/cmp/#mongodb-expression-exp.-cmp
982 */
983 $cmp: [Record<string, AnyExpression> | Expression, Record<string, AnyExpression> | Expression];
984 }
985
986 export interface Eq {
987 /**
988 * Returns true if the values are equivalent.
989 *
990 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/eq/#mongodb-expression-exp.-eq
991 */
992 $eq: AnyExpression | [AnyExpression, AnyExpression];
993 }
994
995 export interface Gt {
996 /**
997 * Returns true if the first value is greater than the second.
998 *
999 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/gt/#mongodb-expression-exp.-gt
1000 */
1001 $gt: NumberExpression | [NumberExpression, NumberExpression];
1002 }
1003
1004 export interface Gte {
1005 /**
1006 * Returns true if the first value is greater than or equal to the second.
1007 *
1008 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/gte/#mongodb-expression-exp.-gte
1009 */
1010 $gte: NumberExpression | [NumberExpression, NumberExpression];
1011 }
1012
1013 export interface Lt {
1014 /**
1015 * Returns true if the first value is less than the second.
1016 *
1017 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/lt/#mongodb-expression-exp.-lt
1018 */
1019 $lt: NumberExpression | [NumberExpression, NumberExpression];
1020 }
1021
1022 export interface Lte {
1023 /**
1024 * Returns true if the first value is less than or equal to the second.
1025 *
1026 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/lte/#mongodb-expression-exp.-lte
1027 */
1028 $lte: NumberExpression | [NumberExpression, NumberExpression];
1029 }
1030
1031 export interface Ne {
1032 /**
1033 * Returns true if the values are not equivalent.
1034 *
1035 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/ne/#mongodb-expression-exp.-ne
1036 */
1037 $ne: Expression | [Expression, Expression | NullExpression] | null;
1038 }
1039
1040 export interface Cond {
1041 /**
1042 * A ternary operator that evaluates one expression, and depending on the result, returns the value of one of the other two expressions. Accepts either three expressions in an ordered list or three named parameters.
1043 *
1044 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/cond/#mongodb-expression-exp.-cond
1045 */
1046 $cond: { if: Expression, then: AnyExpression, else: AnyExpression } | [BooleanExpression, AnyExpression, AnyExpression];
1047 }
1048
1049 export interface IfNull {
1050 /**
1051 * Returns either the non-null result of the first expression or the result of the second expression if the first expression results in a null result. Null result encompasses instances of undefined values or missing fields. Accepts two expressions as arguments. The result of the second expression can be null.
1052 *
1053 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/ifNull/#mongodb-expression-exp.-ifNull
1054 */
1055 $ifNull: Expression[];
1056 }
1057
1058 export interface Switch {
1059 /**
1060 * Evaluates a series of case expressions. When it finds an expression which evaluates to true, $switch executes a specified expression and breaks out of the control flow.
1061 *
1062 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/switch/#mongodb-expression-exp.-switch
1063 */
1064 $switch: {
1065 /**
1066 * An array of control branch documents. Each branch is a document with the following fields:
1067 * - $case
1068 * - $then
1069 */
1070 branches: { case: Expression, then: Expression }[];
1071 /**
1072 * The path to take if no branch case expression evaluates to true.
1073 *
1074 * Although optional, if default is unspecified and no branch case evaluates to true, $switch returns an error.
1075 */
1076 default: Expression;
1077 };
1078 }
1079
1080 export interface ArrayElemAt {
1081 /**
1082 * Returns the element at the specified array index.
1083 *
1084 * @version 3.2
1085 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/arrayElemAt/#mongodb-expression-exp.-arrayElemAt
1086 */
1087 $arrayElemAt: [ArrayExpression, NumberExpression];
1088 }
1089
1090 export interface ArrayToObject {
1091 /**
1092 * Converts an array of key value pairs to a document.
1093 *
1094 * @version 3.4.4
1095 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/arrayToObject/#mongodb-expression-exp.-arrayToObject
1096 */
1097 $arrayToObject: ArrayExpression;
1098 }
1099
1100 export interface ConcatArrays {
1101 /**
1102 * Concatenates arrays to return the concatenated array.
1103 *
1104 * @version 3.2
1105 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/concatArrays/#mongodb-expression-exp.-concatArrays
1106 */
1107 $concatArrays: Expression[];
1108 }
1109
1110 export interface Filter {
1111 /**
1112 * Selects a subset of the array to return an array with only the elements that match the filter condition.
1113 *
1114 * @version 3.2
1115 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/filter/#mongodb-expression-exp.-filter
1116 */
1117 $filter: {
1118 /**
1119 * An expression that resolves to an array.
1120 */
1121 input: ArrayExpression;
1122 /**
1123 * A name for the variable that represents each individual element of the input array. If no name is specified, the variable name defaults to this.
1124 */
1125 as?: string;
1126 /**
1127 * An expression that resolves to a boolean value used to determine if an element should be included in the output array. The expression references each element of the input array individually with the variable name specified in as.
1128 */
1129 cond: BooleanExpression;
1130 /**
1131 * A number expression that restricts the number of matching array elements that $filter returns. You cannot specify a limit less than 1. The matching array elements are returned in the order they appear in the input array.
1132 *
1133 * If the specified limit is greater than the number of matching array elements, $filter returns all matching array elements.
1134 * If the limit is null, $filter returns all matching array elements.
1135 *
1136 * @version 5.2
1137 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/filter/#using-the-limit-field
1138 */
1139 limit?: NumberExpression;
1140 }
1141 }
1142
1143 export interface First {
1144 /**
1145 * Returns the first array element. Distinct from $first accumulator.
1146 *
1147 * @version 5.0
1148 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/first/#mongodb-expression-exp.-first
1149 */
1150 $first: Expression;
1151 }
1152
1153 export interface In {
1154 /**
1155 * Returns a boolean indicating whether a specified value is in an array.
1156 *
1157 * @version 3.4
1158 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/in/#mongodb-expression-exp.-in
1159 */
1160 $in: [Expression, ArrayExpression];
1161 }
1162
1163 export interface IndexOfArray {
1164 /**
1165 * Searches an array for an occurrence of a specified value and returns the array index of the first occurrence. If the substring is not found, returns -1.
1166 *
1167 * @version 3.4
1168 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexOfArray/#mongodb-expression-exp.-indexOfArray
1169 */
1170 $indexOfArray: [ArrayExpression, Expression] | [ArrayExpression, Expression, NumberExpression] | [ArrayExpression, Expression, NumberExpression, NumberExpression];
1171 }
1172
1173 export interface IsArray {
1174 /**
1175 * Determines if the operand is an array. Returns a boolean.
1176 *
1177 * @version 3.2
1178 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/isArray/#mongodb-expression-exp.-isArray
1179 */
1180 $isArray: [Expression];
1181 }
1182
1183 export interface Last {
1184 /**
1185 * Returns the last array element. Distinct from $last accumulator.
1186 *
1187 * @version 5.0
1188 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/last/#mongodb-expression-exp.-last
1189 */
1190 $last: Expression;
1191 }
1192
1193 export interface LinearFill {
1194 /**
1195 * Fills null and missing fields in a window using linear interpolation based on surrounding field values.
1196 *
1197 * @version 5.3
1198 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/linearFill
1199 */
1200 $linearFill: Expression
1201 }
1202
1203 export interface Locf {
1204 /**
1205 * Last observation carried forward. Sets values for null and missing fields in a window to the last non-null value for the field.
1206 *
1207 * @version 5.2
1208 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/locf
1209 */
1210 $locf: Expression
1211 }
1212
1213 export interface Map {
1214 /**
1215 * Applies a subexpression to each element of an array and returns the array of resulting values in order. Accepts named parameters.
1216 *
1217 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/map/#mongodb-expression-exp.-map
1218 */
1219 $map: {
1220 /**
1221 * An expression that resolves to an array.
1222 */
1223 input: ArrayExpression;
1224 /**
1225 * A name for the variable that represents each individual element of the input array. If no name is specified, the variable name defaults to this.
1226 */
1227 as?: string;
1228 /**
1229 * An expression that is applied to each element of the input array. The expression references each element individually with the variable name specified in as.
1230 */
1231 in: Expression;
1232 };
1233 }
1234
1235 export interface ObjectToArray {
1236 /**
1237 * Converts a document to an array of documents representing key-value pairs.
1238 *
1239 * @version 3.4.4
1240 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/objectToArray/#mongodb-expression-exp.-objectToArray
1241 */
1242 $objectToArray: ObjectExpression;
1243 }
1244
1245 export interface Range {
1246 /**
1247 * Outputs an array containing a sequence of integers according to user-defined inputs.
1248 *
1249 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/range/#mongodb-expression-exp.-range
1250 */
1251 $range: [NumberExpression, NumberExpression] | [NumberExpression, NumberExpression, NumberExpression];
1252 }
1253
1254 export interface Reduce {
1255 /**
1256 * Applies an expression to each element in an array and combines them into a single value.
1257 *
1258 * @version 3.4
1259 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/reduce/#mongodb-expression-exp.-reduce
1260 */
1261 $reduce: {
1262 /**
1263 * Can be any valid expression that resolves to an array. For more information on expressions, see Expressions.
1264 *
1265 * If the argument resolves to a value of null or refers to a missing field, $reduce returns null.
1266 *
1267 * If the argument does not resolve to an array or null nor refers to a missing field, $reduce returns an error.
1268 */
1269 input: ArrayExpression;
1270 /**
1271 * The initial cumulative value set before in is applied to the first element of the input array.
1272 */
1273 initialValue: Expression;
1274 /**
1275 * A valid expression that $reduce applies to each element in the input array in left-to-right order. Wrap the input value with $reverseArray to yield the equivalent of applying the combining expression from right-to-left.
1276 *
1277 * During evaluation of the in expression, two variables will be available:
1278 * - `value` is the variable that represents the cumulative value of the expression.
1279 * - `this` is the variable that refers to the element being processed.
1280 */
1281 in: Expression;
1282 };
1283 }
1284
1285 export interface ReverseArray {
1286 /**
1287 * Returns an array with the elements in reverse order.
1288 *
1289 * @version 3.4
1290 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/reverseArray/#mongodb-expression-exp.-reverseArray
1291 */
1292 $reverseArray: ArrayExpression;
1293 }
1294
1295 export interface Size {
1296 /**
1297 * Returns the number of elements in the array. Accepts a single expression as argument.
1298 *
1299 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/size/#mongodb-expression-exp.-size
1300 */
1301 $size: ArrayExpression;
1302 }
1303
1304 export interface Slice {
1305 /**
1306 * Returns a subset of an array.
1307 *
1308 * @version 3.2
1309 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/slice/#mongodb-expression-exp.-slice
1310 */
1311 $slice: [ArrayExpression, NumberExpression] | [ArrayExpression, NumberExpression, NumberExpression];
1312 }
1313
1314 export interface Zip {
1315 /**
1316 * Merge two arrays together.
1317 *
1318 * @version 3.4
1319 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/zip/#mongodb-expression-exp.-zip
1320 */
1321 $zip: {
1322 /**
1323 * An array of expressions that resolve to arrays. The elements of these input arrays combine to form the arrays of the output array.
1324 *
1325 * If any of the inputs arrays resolves to a value of null or refers to a missing field, $zip returns null.
1326 *
1327 * If any of the inputs arrays does not resolve to an array or null nor refers to a missing field, $zip returns an error.
1328 */
1329 inputs: ArrayExpression[];
1330 /**
1331 * A boolean which specifies whether the length of the longest array determines the number of arrays in the output array.
1332 *
1333 * The default value is false: the shortest array length determines the number of arrays in the output array.
1334 */
1335 useLongestLength?: boolean;
1336 /**
1337 * An array of default element values to use if the input arrays have different lengths. You must specify useLongestLength: true along with this field, or else $zip will return an error.
1338 *
1339 * If useLongestLength: true but defaults is empty or not specified, $zip uses null as the default value.
1340 *
1341 * If specifying a non-empty defaults, you must specify a default for each input array or else $zip will return an error.
1342 */
1343 defaults?: ArrayExpression;
1344 };
1345 }
1346
1347 export interface Concat {
1348 /**
1349 * Concatenates any number of strings.
1350 *
1351 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/concat/#mongodb-expression-exp.-concat
1352 */
1353 $concat: StringExpression[];
1354 }
1355
1356 export interface IndexOfBytes {
1357 /**
1358 * Searches a string for an occurrence of a substring and returns the UTF-8 byte index of the first occurrence. If the substring is not found, returns -1.
1359 *
1360 * @version 3.4
1361 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexOfBytes/#mongodb-expression-exp.-indexOfBytes
1362 */
1363 $indexOfBytes: [StringExpression, StringExpression] | [StringExpression, StringExpression, NumberExpression] | [StringExpression, StringExpression, NumberExpression, NumberExpression];
1364 }
1365
1366 export interface IndexOfCP {
1367 /**
1368 * Searches a string for an occurrence of a substring and returns the UTF-8 code point index of the first occurrence. If the substring is not found, returns -1
1369 *
1370 * @version 3.4
1371 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexOfCP/#mongodb-expression-exp.-indexOfCP
1372 */
1373 $indexOfCP: [StringExpression, StringExpression] | [StringExpression, StringExpression, NumberExpression] | [StringExpression, StringExpression, NumberExpression, NumberExpression];
1374 }
1375
1376 export interface Ltrim {
1377 /**
1378 * Removes whitespace or the specified characters from the beginning of a string.
1379 *
1380 * @version 4.0
1381 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/ltrim/#mongodb-expression-exp.-ltrim
1382 */
1383 $ltrim: {
1384 /**
1385 * The string to trim. The argument can be any valid expression that resolves to a string. For more information on expressions, see Expressions.
1386 */
1387 input: StringExpression;
1388 /**
1389 * The character(s) to trim from the beginning of the input.
1390 *
1391 * The argument can be any valid expression that resolves to a string. The $ltrim operator breaks down the string into individual UTF code point to trim from input.
1392 *
1393 * If unspecified, $ltrim removes whitespace characters, including the null character. For the list of whitespace characters, see Whitespace Characters.
1394 */
1395 chars?: StringExpression;
1396 };
1397 }
1398
1399 export interface RegexFind {
1400 /**
1401 * Applies a regular expression (regex) to a string and returns information on the first matched substring.
1402 *
1403 * @version 4.2
1404 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexFind/#mongodb-expression-exp.-regexFind
1405 */
1406 $regexFind: {
1407 /**
1408 * The string on which you wish to apply the regex pattern. Can be a string or any valid expression that resolves to a string.
1409 */
1410 input: Expression; // TODO: Resolving to string, which ones?
1411 /**
1412 * The regex pattern to apply. Can be any valid expression that resolves to either a string or regex pattern /<pattern>/. When using the regex /<pattern>/, you can also specify the regex options i and m (but not the s or x options):
1413 * - "pattern"
1414 * - /pattern/
1415 * - /pattern/options
1416 *
1417 * Alternatively, you can also specify the regex options with the options field. To specify the s or x options, you must use the options field.
1418 *
1419 * You cannot specify options in both the regex and the options field.
1420 */
1421 regex: RegExp | string;
1422 /**
1423 * The following <options> are available for use with regular expression.
1424 *
1425 * Note: You cannot specify options in both the regex and the options field.
1426 *
1427 * Option Description
1428 *
1429 * `i` Case insensitivity to match both upper and lower cases. You can specify the option in the options field or as part of the regex field.
1430 *
1431 * `m` For patterns that include anchors (i.e. ^ for the start, $ for the end), match at the beginning or end of each line for strings with multiline values. Without this option, these anchors match at beginning or end of the string.
1432 * If the pattern contains no anchors or if the string value has no newline characters (e.g. \n), the m option has no effect.
1433 *
1434 * `x` "Extended" capability to ignore all white space characters in the pattern unless escaped or included in a character class.
1435 * Additionally, it ignores characters in-between and including an un-escaped hash/pound (#) character and the next new line, so that you may include comments in complicated patterns. This only applies to data characters; white space characters may never appear within special character sequences in a pattern.
1436 * The x option does not affect the handling of the VT character (i.e. code 11).
1437 * You can specify the option only in the options field.
1438 *
1439 * `s` Allows the dot character (i.e. .) to match all characters including newline characters.
1440 * You can specify the option only in the options field.
1441 */
1442 options?: RegexOptions;
1443 };
1444 }
1445
1446 export interface RegexFindAll {
1447 /**
1448 * Applies a regular expression (regex) to a string and returns information on the all matched substrings.
1449 *
1450 * @version 4.2
1451 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexFindAll/#mongodb-expression-exp.-regexFindAll
1452 */
1453 $regexFindAll: {
1454 /**
1455 * The string on which you wish to apply the regex pattern. Can be a string or any valid expression that resolves to a string.
1456 */
1457 input: Expression; // TODO: Resolving to string, which ones?
1458 /**
1459 * The regex pattern to apply. Can be any valid expression that resolves to either a string or regex pattern /<pattern>/. When using the regex /<pattern>/, you can also specify the regex options i and m (but not the s or x options):
1460 * - "pattern"
1461 * - /pattern/
1462 * - /pattern/options
1463 *
1464 * Alternatively, you can also specify the regex options with the options field. To specify the s or x options, you must use the options field.
1465 *
1466 * You cannot specify options in both the regex and the options field.
1467 */
1468 regex: RegExp | string;
1469 /**
1470 * The following <options> are available for use with regular expression.
1471 *
1472 * Note: You cannot specify options in both the regex and the options field.
1473 *
1474 * Option Description
1475 *
1476 * `i` Case insensitivity to match both upper and lower cases. You can specify the option in the options field or as part of the regex field.
1477 *
1478 * `m` For patterns that include anchors (i.e. ^ for the start, $ for the end), match at the beginning or end of each line for strings with multiline values. Without this option, these anchors match at beginning or end of the string.
1479 * If the pattern contains no anchors or if the string value has no newline characters (e.g. \n), the m option has no effect.
1480 *
1481 * `x` "Extended" capability to ignore all white space characters in the pattern unless escaped or included in a character class.
1482 * Additionally, it ignores characters in-between and including an un-escaped hash/pound (#) character and the next new line, so that you may include comments in complicated patterns. This only applies to data characters; white space characters may never appear within special character sequences in a pattern.
1483 * The x option does not affect the handling of the VT character (i.e. code 11).
1484 * You can specify the option only in the options field.
1485 *
1486 * `s` Allows the dot character (i.e. .) to match all characters including newline characters.
1487 * You can specify the option only in the options field.
1488 */
1489 options?: RegexOptions;
1490 };
1491 }
1492
1493 export interface RegexMatch {
1494 /**
1495 * Applies a regular expression (regex) to a string and returns a boolean that indicates if a match is found or not.
1496 *
1497 * @version 4.2
1498 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexMatch/#mongodb-expression-exp.-regexMatch
1499 */
1500 $regexMatch: {
1501 /**
1502 * The string on which you wish to apply the regex pattern. Can be a string or any valid expression that resolves to a string.
1503 */
1504 input: Expression; // TODO: Resolving to string, which ones?
1505 /**
1506 * The regex pattern to apply. Can be any valid expression that resolves to either a string or regex pattern /<pattern>/. When using the regex /<pattern>/, you can also specify the regex options i and m (but not the s or x options):
1507 * - "pattern"
1508 * - /pattern/
1509 * - /pattern/options
1510 *
1511 * Alternatively, you can also specify the regex options with the options field. To specify the s or x options, you must use the options field.
1512 *
1513 * You cannot specify options in both the regex and the options field.
1514 */
1515 regex: RegExp | string;
1516 /**
1517 * The following <options> are available for use with regular expression.
1518 *
1519 * Note: You cannot specify options in both the regex and the options field.
1520 *
1521 * Option Description
1522 *
1523 * `i` Case insensitivity to match both upper and lower cases. You can specify the option in the options field or as part of the regex field.
1524 *
1525 * `m` For patterns that include anchors (i.e. ^ for the start, $ for the end), match at the beginning or end of each line for strings with multiline values. Without this option, these anchors match at beginning or end of the string.
1526 * If the pattern contains no anchors or if the string value has no newline characters (e.g. \n), the m option has no effect.
1527 *
1528 * `x` "Extended" capability to ignore all white space characters in the pattern unless escaped or included in a character class.
1529 * Additionally, it ignores characters in-between and including an un-escaped hash/pound (#) character and the next new line, so that you may include comments in complicated patterns. This only applies to data characters; white space characters may never appear within special character sequences in a pattern.
1530 * The x option does not affect the handling of the VT character (i.e. code 11).
1531 * You can specify the option only in the options field.
1532 *
1533 * `s` Allows the dot character (i.e. .) to match all characters including newline characters.
1534 * You can specify the option only in the options field.
1535 */
1536 options?: RegexOptions;
1537 };
1538 }
1539
1540 export interface ReplaceOne {
1541 /**
1542 * Replaces the first instance of a matched string in a given input.
1543 *
1544 * @version 4.4
1545 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceOne/#mongodb-expression-exp.-replaceOne
1546 */
1547 $replaceOne: {
1548 /**
1549 * The string on which you wish to apply the find. Can be any valid expression that resolves to a string or a null. If input refers to a field that is missing, $replaceOne returns null.
1550 */
1551 input: StringExpression;
1552 /**
1553 * The string to search for within the given input. Can be any valid expression that resolves to a string or a null. If find refers to a field that is missing, $replaceOne returns null.
1554 */
1555 find: StringExpression;
1556 /**
1557 * The string to use to replace the first matched instance of find in input. Can be any valid expression that resolves to a string or a null.
1558 */
1559 replacement: StringExpression;
1560 };
1561 }
1562
1563 export interface ReplaceAll {
1564 /**
1565 * Replaces all instances of a matched string in a given input.
1566 *
1567 * @version 4.4
1568 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceAll/#mongodb-expression-exp.-replaceAll
1569 */
1570 $replaceAll: {
1571 /**
1572 * The string on which you wish to apply the find. Can be any valid expression that resolves to a string or a null. If input refers to a field that is missing, $replaceAll returns null.
1573 */
1574 input: StringExpression;
1575 /**
1576 * The string to search for within the given input. Can be any valid expression that resolves to a string or a null. If find refers to a field that is missing, $replaceAll returns null.
1577 */
1578 find: StringExpression;
1579 /**
1580 * The string to use to replace all matched instances of find in input. Can be any valid expression that resolves to a string or a null.
1581 */
1582 replacement: StringExpression;
1583 };
1584 }
1585
1586 export interface Rtrim {
1587 /**
1588 * Removes whitespace or the specified characters from the end of a string.
1589 *
1590 * @version 4.0
1591 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/rtrim/#mongodb-expression-exp.-rtrim
1592 */
1593 $rtrim: {
1594 /**
1595 * The string to trim. The argument can be any valid expression that resolves to a string. For more information on expressions, see Expressions.
1596 */
1597 input: StringExpression;
1598 /**
1599 * The character(s) to trim from the beginning of the input.
1600 *
1601 * The argument can be any valid expression that resolves to a string. The $rtrim operator breaks down the string into individual UTF code point to trim from input.
1602 *
1603 * If unspecified, $rtrim removes whitespace characters, including the null character. For the list of whitespace characters, see Whitespace Characters.
1604 */
1605 chars?: StringExpression;
1606 };
1607 }
1608
1609 export interface Split {
1610 /**
1611 * Splits a string into substrings based on a delimiter. Returns an array of substrings. If the delimiter is not found within the string, returns an array containing the original string.
1612 *
1613 * @version 3.4
1614 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/split/#mongodb-expression-exp.-split
1615 */
1616 $split: [StringExpression, StringExpression];
1617 }
1618
1619 export interface StrLenBytes {
1620 /**
1621 * Returns the number of UTF-8 encoded bytes in a string.
1622 *
1623 * @version 3.4
1624 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/strLenBytes/#mongodb-expression-exp.-strLenBytes
1625 */
1626 $strLenBytes: StringExpression;
1627 }
1628
1629 export interface StrLenCP {
1630 /**
1631 * Returns the number of UTF-8 code points in a string.
1632 *
1633 * @version 3.4
1634 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/strLenCP/#mongodb-expression-exp.-strLenCP
1635 */
1636 $strLenCP: StringExpression;
1637 }
1638
1639 export interface Strcasecmp {
1640 /**
1641 * Performs case-insensitive string comparison and returns: 0 if two strings are equivalent, 1 if the first string is greater than the second, and -1 if the first string is less than the second.
1642 *
1643 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/strcasecmp/#mongodb-expression-exp.-strcasecmp
1644 */
1645 $strcasecmp: [StringExpression, StringExpression];
1646 }
1647
1648 export interface Substr {
1649 /**
1650 * Deprecated. Use $substrBytes or $substrCP.
1651 *
1652 * @deprecated 3.4
1653 * @alias {Expression.SubstrBytes}
1654 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/substr/#mongodb-expression-exp.-substr
1655 */
1656 $substr: [StringExpression, number, number];
1657 }
1658
1659 export interface SubstrBytes {
1660 /**
1661 * Returns the substring of a string. Starts with the character at the specified UTF-8 byte index (zero-based) in the string and continues for the specified number of bytes.
1662 *
1663 * @version 3.4
1664 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/substrBytes/#mongodb-expression-exp.-substrBytes
1665 */
1666 $substrBytes: [StringExpression, number, number];
1667 }
1668
1669 export interface SubstrCP {
1670 /**
1671 * Returns the substring of a string. Starts with the character at the specified UTF-8 code point (CP) index (zero-based) in the string and continues for the number of code points specified.
1672 *
1673 * @version 3.4
1674 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/substrCP/#mongodb-expression-exp.-substrCP
1675 */
1676 $substrCP: [StringExpression, number, number];
1677 }
1678
1679 export interface ToLower {
1680 /**
1681 * Converts a string to lowercase. Accepts a single argument expression.
1682 *
1683 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toLower/#mongodb-expression-exp.-toLower
1684 */
1685 $toLower: StringExpression;
1686 }
1687
1688 export interface ToString {
1689 /**
1690 * Converts value to a string.
1691 *
1692 * @version 4.0
1693 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toString/#mongodb-expression-exp.-toString
1694 */
1695 $toString: Expression;
1696 }
1697
1698 export interface Trim {
1699 /**
1700 * Removes whitespace or the specified characters from the beginning and end of a string.
1701 *
1702 * @version 4.0
1703 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/trim/#mongodb-expression-exp.-trim
1704 */
1705 $trim: {
1706 /**
1707 * The string to trim. The argument can be any valid expression that resolves to a string. For more information on expressions, see Expressions.
1708 */
1709 input: StringExpression;
1710 /**
1711 * The character(s) to trim from the beginning of the input.
1712 *
1713 * The argument can be any valid expression that resolves to a string. The $trim operator breaks down the string into individual UTF code point to trim from input.
1714 *
1715 * If unspecified, $trim removes whitespace characters, including the null character. For the list of whitespace characters, see Whitespace Characters.
1716 */
1717 chars?: StringExpression;
1718 };
1719 }
1720
1721 export interface ToUpper {
1722 /**
1723 * Converts a string to uppercase. Accepts a single argument expression.
1724 *
1725 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toUpper/#mongodb-expression-exp.-toUpper
1726 */
1727 $toUpper: StringExpression;
1728 }
1729
1730 export interface Literal {
1731
1732 /**
1733 * Returns a value without parsing. Use for values that the aggregation pipeline may interpret as an
1734 * expression.
1735 *
1736 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/literal/#mongodb-expression-exp.-literal
1737 */
1738 $literal: any;
1739 }
1740
1741 export interface GetField {
1742
1743 /**
1744 * Returns the value of a specified field from a document. If you don't specify an object, $getField returns
1745 * the value of the field from $$CURRENT.
1746 *
1747 * @version 4.4.2
1748 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/getField/#mongodb-expression-exp.-getField
1749 */
1750 $getField: {
1751 /**
1752 * Field in the input object for which you want to return a value. field can be any valid expression that
1753 * resolves to a string constant.
1754 */
1755 field: StringExpression;
1756 /**
1757 * A valid expression that contains the field for which you want to return a value. input must resolve to an
1758 * object, missing, null, or undefined. If omitted, defaults to the document currently being processed in the
1759 * pipeline ($$CURRENT).
1760 */
1761 input?: ObjectExpression | SpecialPathVariables | NullExpression;
1762 }
1763 }
1764
1765 export interface Rand {
1766
1767 /**
1768 * Returns a random float between 0 and 1 each time it is called.
1769 *
1770 * @version 4.4.2
1771 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/rand/#mongodb-expression-exp.-rand
1772 */
1773 $rand: Record<string | number | symbol, never>;
1774 }
1775
1776 export interface SampleRate {
1777
1778 /**
1779 * Matches a random selection of input documents. The number of documents selected approximates the sample
1780 * rate expressed as a percentage of the total number of documents.
1781 *
1782 * @version 4.4.2
1783 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/sampleRate/#mongodb-expression-exp.-sampleRate
1784 */
1785 $sampleRate: number;
1786 }
1787
1788 export interface MergeObjects {
1789
1790 /**
1791 * Combines multiple documents into a single document.
1792 *
1793 * @version 3.6
1794 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/mergeObjects/#mongodb-expression-exp.-mergeObjects
1795 */
1796 $mergeObjects: ObjectExpression | ObjectExpression[] | ArrayExpression | Record<string, string>;
1797 }
1798
1799 export interface SetField {
1800
1801 /**
1802 * Adds, updates, or removes a specified field in a document.
1803 *
1804 * @version 5.0
1805 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/setField/#mongodb-expression-exp.-setField
1806 */
1807 $setField: {
1808 /**
1809 * Field in the input object that you want to add, update, or remove. field can be any valid expression that
1810 * resolves to a string constant.
1811 */
1812 field: StringExpression;
1813 /**
1814 * Document that contains the field that you want to add or update. input must resolve to an object, missing,
1815 * null, or undefined
1816 */
1817 input?: ObjectExpression | NullExpression;
1818 /**
1819 * The value that you want to assign to field. value can be any valid expression.
1820 */
1821 value?: Expression | SpecialPathVariables;
1822 }
1823 }
1824
1825 export interface UnsetField {
1826
1827 /**
1828 * Removes a specified field in a document.
1829 *
1830 * @version 5.0
1831 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/unsetField/#mongodb-expression-exp.-unsetField
1832 */
1833 $unsetField: {
1834 /**
1835 * Field in the input object that you want to add, update, or remove. field can be any valid expression that
1836 * resolves to a string constant.
1837 */
1838 field: StringExpression;
1839 /**
1840 * Document that contains the field that you want to add or update. input must resolve to an object, missing,
1841 * null, or undefined.
1842 */
1843 input?: ObjectExpression | SpecialPathVariables | NullExpression;
1844 }
1845 }
1846
1847 export interface Let {
1848
1849 /**
1850 * Binds variables for use in the specified expression, and returns the result of the expression.
1851 *
1852 * @version 5.0
1853 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/let/#mongodb-expression-exp.-let
1854 */
1855 $let: {
1856 /**
1857 * Assignment block for the variables accessible in the in expression. To assign a variable, specify a
1858 * string for the variable name and assign a valid expression for the value.
1859 */
1860 vars: { [key: string]: Expression; };
1861 /**
1862 * The expression to evaluate.
1863 */
1864 in: Expression;
1865 }
1866 }
1867
1868 export interface AllElementsTrue {
1869 /**
1870 * Evaluates an array as a set and returns true if no element in the array is false. Otherwise, returns false. An
1871 * empty array returns true.
1872 *
1873 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/allElementsTrue/#mongodb-expression-exp.-allElementsTrue
1874 */
1875 $allElementsTrue: ArrayExpression;
1876 }
1877
1878 export interface AnyElementsTrue {
1879 /**
1880 * Evaluates an array as a set and returns true if any of the elements are true and false otherwise. An empty
1881 * array returns false.
1882 *
1883 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/anyElementsTrue/#mongodb-expression-exp.-anyElementsTrue
1884 */
1885 $anyElementTrue: ArrayExpression;
1886 }
1887
1888 export interface SetDifference {
1889 /**
1890 * Takes two sets and returns an array containing the elements that only exist in the first set; i.e. performs a
1891 * relative complement of the second set relative to the first.
1892 *
1893 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/setDifference/#mongodb-expression-exp.-setDifference
1894 */
1895 $setDifference: [ArrayExpression, ArrayExpression];
1896 }
1897
1898 export interface SetEquals {
1899 /**
1900 * Compares two or more arrays and returns true if they have the same distinct elements and false otherwise.
1901 *
1902 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/setEquals/#mongodb-expression-exp.-setEquals
1903 */
1904 $setEquals: ArrayExpression[];
1905 }
1906
1907 export interface SetIntersection {
1908 /**
1909 * Takes two or more arrays and returns an array that contains the elements that appear in every input array.
1910 *
1911 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/setIntersection/#mongodb-expression-exp.-setIntersection
1912 */
1913 $setIntersection: ArrayExpression[];
1914 }
1915
1916 export interface SetIsSubset {
1917 /**
1918 * Takes two arrays and returns true when the first array is a subset of the second, including when the first
1919 * array equals the second array, and false otherwise.
1920 *
1921 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/setIsSubset/#mongodb-expression-exp.-setIsSubset
1922 */
1923 $setIsSubset: [ArrayExpression, ArrayExpression];
1924 }
1925
1926 export interface SetUnion {
1927 /**
1928 * Takes two or more arrays and returns an array containing the elements that appear in any input array.
1929 *
1930 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/setUnion/#mongodb-expression-exp.-setUnion
1931 */
1932 $setUnion: ArrayExpression[];
1933 }
1934
1935 export interface Accumulator {
1936 /**
1937 * Defines a custom accumulator operator. Accumulators are operators that maintain their state (e.g. totals,
1938 * maximums, minimums, and related data) as documents progress through the pipeline. Use the $accumulator operator
1939 * to execute your own JavaScript functions to implement behavior not supported by the MongoDB Query Language. See
1940 * also $function.
1941 *
1942 * @version 4.4
1943 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/accumulator/#mongodb-expression-exp.-accumulator
1944 */
1945 $accumulator: {
1946 /**
1947 * Function used to initialize the state. The init function receives its arguments from the initArgs array
1948 * expression. You can specify the function definition as either BSON type Code or String.
1949 */
1950 init: CodeExpression;
1951 /**
1952 * Arguments passed to the init function.
1953 */
1954 initArgs?: ArrayExpression;
1955 /**
1956 * Function used to accumulate documents. The accumulate function receives its arguments from the current state
1957 * and accumulateArgs array expression. The result of the accumulate function becomes the new state. You can
1958 * specify the function definition as either BSON type Code or String.
1959 */
1960 accumulate: CodeExpression;
1961 /**
1962 * Arguments passed to the accumulate function. You can use accumulateArgs to specify what field value(s) to
1963 * pass to the accumulate function.
1964 */
1965 accumulateArgs: ArrayExpression;
1966 /**
1967 * Function used to merge two internal states. merge must be either a String or Code BSON type. merge returns
1968 * the combined result of the two merged states. For information on when the merge function is called, see Merge
1969 * Two States with $merge.
1970 */
1971 merge: CodeExpression;
1972 /**
1973 * Function used to update the result of the accumulation.
1974 */
1975 finalize?: CodeExpression;
1976 /**
1977 * The language used in the $accumulator code.
1978 */
1979 lang: 'js';
1980 }
1981 }
1982
1983 export interface AddToSet {
1984 /**
1985 * Returns an array of all unique values that results from applying an expression to each document in a group.
1986 *
1987 * @version 5.0
1988 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/addToSet/#mongodb-expression-exp.-addToSet
1989 */
1990 $addToSet: Expression | Record<string, Expression>;
1991 }
1992
1993 export interface Avg {
1994 /**
1995 * Returns the average value of the numeric values. $avg ignores non-numeric values.
1996 *
1997 * @version 5.0
1998 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/avg/#mongodb-expression-exp.-avg
1999 */
2000 $avg: Expression;
2001 }
2002
2003 export interface Count {
2004 /**
2005 * Returns the number of documents in a group.
2006 *
2007 * @version 5.0
2008 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/count/#mongodb-expression-exp.-count
2009 */
2010 $count: Record<string | number | symbol, never> | Path;
2011 }
2012
2013 export interface CovariancePop {
2014 /**
2015 * Returns the population covariance of two numeric expressions that are evaluated using documents in the
2016 * $setWindowFields stage window.
2017 *
2018 * @version 5.0
2019 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/covariancePop/#mongodb-expression-exp.-covariancePop
2020 */
2021 $covariancePop: [NumberExpression, NumberExpression];
2022 }
2023
2024 export interface CovarianceSamp {
2025 /**
2026 * Returns the sample covariance of two numeric expressions that are evaluated using documents in the
2027 * $setWindowFields stage window.
2028 *
2029 * @version 5.0
2030 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/covarianceSamp/#mongodb-expression-exp.-covarianceSamp
2031 */
2032 $covarianceSamp: [NumberExpression, NumberExpression];
2033 }
2034
2035 export interface DenseRank {
2036 /**
2037 * Returns the document position (known as the rank) relative to other documents in the $setWindowFields stage
2038 * partition.
2039 *
2040 * @version 5.0
2041 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/denseRank/#mongodb-expression-exp.-denseRank
2042 */
2043 $denseRank: Record<string | number | symbol, never>;
2044 }
2045
2046 export interface Derivative {
2047 /**
2048 * Returns the average rate of change within the specified window, which is calculated using the:
2049 *
2050 * @version 5.0
2051 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/derivative/#mongodb-expression-exp.-derivative
2052 */
2053 $derivative: {
2054 /**
2055 * Specifies the expression to evaluate. The expression must evaluate to a number.
2056 */
2057 input: NumberExpression;
2058 /**
2059 * A string that specifies the time unit.
2060 */
2061 unit?: DateUnit;
2062 }
2063 }
2064
2065 export interface DocumentNumber {
2066 /**
2067 * Returns the position of a document (known as the document number) in the $setWindowFields stage partition.
2068 *
2069 * @version 5.0
2070 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/documentNumber/#mongodb-expression-exp.-documentNumber
2071 */
2072 $documentNumber: Record<string | number | symbol, never>;
2073 }
2074
2075 export interface ExpMovingAvg {
2076 /**
2077 * Returns the exponential moving average of numeric expressions applied to documents in a partition defined in
2078 * the $setWindowFields stage.
2079 *
2080 * @version 5.0
2081 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/expMovingAvg/#mongodb-expression-exp.-expMovingAvg
2082 */
2083 $expMovingAvg: {
2084 /**
2085 * Specifies the expression to evaluate. Non-numeric expressions are ignored.
2086 */
2087 input: Expression;
2088
2089 /**
2090 * An integer that specifies the number of historical documents that have a significant mathematical weight in
2091 * the exponential moving average calculation, with the most recent documents contributing the most weight.
2092 *
2093 * You must specify either N or alpha. You cannot specify both.
2094 */
2095 N: NumberExpression;
2096
2097 /**
2098 * A double that specifies the exponential decay value to use in the exponential moving average calculation. A
2099 * higher alpha value assigns a lower mathematical significance to previous results from the calculation.
2100 *
2101 * You must specify either N or alpha. You cannot specify both.
2102 */
2103 alpha?: never;
2104 } |
2105 {
2106 /**
2107 * Specifies the expression to evaluate. Non-numeric expressions are ignored.
2108 */
2109 input: Expression;
2110
2111 /**
2112 * An integer that specifies the number of historical documents that have a significant mathematical weight in
2113 * the exponential moving average calculation, with the most recent documents contributing the most weight.
2114 *
2115 * You must specify either N or alpha. You cannot specify both.
2116 */
2117 N?: never;
2118
2119 /**
2120 * A double that specifies the exponential decay value to use in the exponential moving average calculation. A
2121 * higher alpha value assigns a lower mathematical significance to previous results from the calculation.
2122 *
2123 * You must specify either N or alpha. You cannot specify both.
2124 */
2125 alpha: NumberExpression;
2126 }
2127 }
2128
2129 export interface Integral {
2130 /**
2131 * Returns the approximation of the area under a curve, which is calculated using the trapezoidal rule where each
2132 * set of adjacent documents form a trapezoid using the:
2133 *
2134 * @version 5.0
2135 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/integral/#mongodb-expression-exp.-integral
2136 */
2137 $integral: {
2138 /**
2139 * Specifies the expression to evaluate. You must provide an expression that returns a number.
2140 */
2141 input: NumberExpression;
2142
2143 /**
2144 * A string that specifies the time unit.
2145 */
2146 unit?: DateUnit;
2147 }
2148 }
2149
2150 export interface Max {
2151 /**
2152 * Returns the maximum value. $max compares both value and type, using the specified BSON comparison order for
2153 * values of different types.
2154 *
2155 * @version 5.0
2156 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/max/#mongodb-expression-exp.-max
2157 */
2158 $max: Expression | Expression[];
2159 }
2160
2161 export interface Min {
2162 /**
2163 * Returns the minimum value. $min compares both value and type, using the specified BSON comparison order for
2164 * values of different types.
2165 *
2166 * @version 5.0
2167 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/min/#mongodb-expression-exp.-min
2168 */
2169 $min: Expression | Expression[];
2170 }
2171
2172 export interface Push {
2173 /**
2174 * Returns an array of all values that result from applying an expression to documents.
2175 *
2176 * @version 5.0
2177 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/push/#mongodb-expression-exp.-push
2178 */
2179 $push: Expression | Record<string, Expression>;
2180 }
2181
2182 export interface Rank {
2183 /**
2184 * Returns the document position (known as the rank) relative to other documents in the $setWindowFields stage
2185 * partition.
2186 *
2187 * @version 5.0
2188 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/rank/#mongodb-expression-exp.-rank
2189 */
2190 $rank: Record<string | number | symbol, never>;
2191 }
2192
2193 export interface Shift {
2194 /**
2195 * Returns the value from an expression applied to a document in a specified position relative to the current
2196 * document in the $setWindowFields stage partition.
2197 *
2198 * @version 5.0
2199 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/shift/#mongodb-expression-exp.-shift
2200 */
2201 $shift: {
2202 /**
2203 * Specifies an expression to evaluate and return in the output.
2204 */
2205 output: Expression;
2206 /**
2207 * Specifies an integer with a numeric document position relative to the current document in the output.
2208 */
2209 by: number;
2210 /**
2211 * Specifies an optional default expression to evaluate if the document position is outside of the implicit
2212 * $setWindowFields stage window. The implicit window contains all the documents in the partition.
2213 */
2214 default?: Expression;
2215 }
2216 }
2217
2218 export interface StdDevPop {
2219 /**
2220 * Calculates the population standard deviation of the input values. Use if the values encompass the entire
2221 * population of data you want to represent and do not wish to generalize about a larger population. $stdDevPop
2222 * ignores non-numeric values.
2223 *
2224 * @version 5.0
2225 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevPop/#mongodb-expression-exp.-stdDevPop
2226 */
2227 $stdDevPop: Expression;
2228 }
2229
2230 export interface StdDevSamp {
2231 /**
2232 * Calculates the sample standard deviation of the input values. Use if the values encompass a sample of a
2233 * population of data from which to generalize about the population. $stdDevSamp ignores non-numeric values.
2234 *
2235 * @version 5.0
2236 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevSamp/#mongodb-expression-exp.-stdDevSamp
2237 */
2238 $stdDevSamp: Expression;
2239 }
2240
2241 export interface Sum {
2242 /**
2243 * Calculates and returns the collective sum of numeric values. $sum ignores non-numeric values.
2244 *
2245 * @version 5.0
2246 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/sum/#mongodb-expression-exp.-sum
2247 */
2248 $sum: number | Expression | Expression[];
2249 }
2250
2251 export interface Convert<K extends 'double' | 1 | 'string' | 2 | 'objectId' | 7 | 'bool' | 8 | 'date' | 9 | 'int' | 16 | 'long' | 18 | 'decimal' | 19 = 'double' | 1 | 'string' | 2 | 'objectId' | 7 | 'bool' | 8 | 'date' | 9 | 'int' | 16 | 'long' | 18 | 'decimal' | 19> {
2252 /**
2253 * Checks if the specified expression resolves to one of the following numeric
2254 * - Integer
2255 * - Decimal
2256 * - Double
2257 * - Long
2258 *
2259 * @version 4.4
2260 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/convert/#mongodb-expression-exp.-convert
2261 */
2262 $convert: {
2263 input: Expression;
2264 to: K;
2265 onError?: Expression;
2266 onNull?: Expression;
2267 };
2268 }
2269
2270 export interface IsNumber {
2271 /**
2272 * Checks if the specified expression resolves to one of the following numeric
2273 * - Integer
2274 * - Decimal
2275 * - Double
2276 * - Long
2277 *
2278 * @version 4.4
2279 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/isNumber/#mongodb-expression-exp.-isNumber
2280 */
2281 $isNumber: Expression;
2282 }
2283
2284 export interface ToBool {
2285 /**
2286 * Converts a value to a boolean.
2287 *
2288 * @version 4.0
2289 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toBool/#mongodb-expression-exp.-toBool
2290 */
2291 $toBool: Expression;
2292 }
2293
2294 export interface ToDecimal {
2295 /**
2296 * Converts a value to a decimal. If the value cannot be converted to a decimal, $toDecimal errors. If the value
2297 * is null or missing, $toDecimal returns null.
2298 *
2299 * @version 4.0
2300 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toDecimal/#mongodb-expression-exp.-toDecimal
2301 */
2302 $toDecimal: Expression;
2303 }
2304
2305 export interface ToDouble {
2306 /**
2307 * Converts a value to a double. If the value cannot be converted to an double, $toDouble errors. If the value is
2308 * null or missing, $toDouble returns null.
2309 *
2310 * @version 4.0
2311 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toDouble/#mongodb-expression-exp.-toDouble
2312 */
2313 $toDouble: Expression;
2314 }
2315
2316 export interface ToInt {
2317 /**
2318 * Converts a value to a long. If the value cannot be converted to a long, $toLong errors. If the value is null or
2319 * missing, $toLong returns null.
2320 *
2321 * @version 4.0
2322 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toInt/#mongodb-expression-exp.-toInt
2323 */
2324 $toInt: Expression;
2325 }
2326
2327 export interface ToLong {
2328 /**
2329 * Converts a value to a long. If the value cannot be converted to a long, $toLong errors. If the value is null or
2330 * missing, $toLong returns null.
2331 *
2332 * @version 4.0
2333 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toLong/#mongodb-expression-exp.-toLong
2334 */
2335 $toLong: Expression;
2336 }
2337
2338 export interface ToObjectId {
2339 /**
2340 * Converts a value to an ObjectId(). If the value cannot be converted to an ObjectId, $toObjectId errors. If the
2341 * value is null or missing, $toObjectId returns null.
2342 *
2343 * @version 4.0
2344 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toObjectId/#mongodb-expression-exp.-toObjectId
2345 */
2346 $toObjectId: Expression;
2347 }
2348
2349 export interface Top {
2350 $top: {
2351 sortBy: AnyObject,
2352 output: Expression
2353 };
2354 }
2355
2356 export interface TopN {
2357 $topN: {
2358 n: Expression,
2359 sortBy: AnyObject,
2360 output: Expression
2361 };
2362 }
2363
2364 export interface ToString {
2365 /**
2366 * Converts a value to a string. If the value cannot be converted to a string, $toString errors. If the value is
2367 * null or missing, $toString returns null.
2368 *
2369 * @version 4.0
2370 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toString/#mongodb-expression-exp.-toString
2371 */
2372 $toString: Expression;
2373 }
2374
2375 export interface Type {
2376 /**
2377 * Returns a string that specifies the BSON type of the argument.
2378 *
2379 * @version 3.4
2380 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/type/#mongodb-expression-exp.-type
2381 */
2382 $type: Expression;
2383 }
2384
2385 export interface BinarySize {
2386 /**
2387 * Returns the size of a given string or binary data value's content in bytes.
2388 *
2389 * @version 4.4
2390 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/binarySize/#mongodb-expression-exp.-binarySize
2391 */
2392 $binarySize: NullExpression | StringExpression | BinaryExpression;
2393 }
2394
2395 export interface BsonSize {
2396 /**
2397 * Returns the size in bytes of a given document (i.e. bsontype Object) when encoded as BSON. You can use
2398 * $bsonSize as an alternative to the Object.bsonSize() method.
2399 *
2400 * @version 4.4
2401 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/bsonSize/#mongodb-expression-exp.-bsonSize
2402 */
2403 $bsonSize: NullExpression | ObjectExpression;
2404 }
2405
2406 export interface Function {
2407 /**
2408 * Defines a custom aggregation function or expression in JavaScript.
2409 *
2410 * @version 4.4
2411 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/function/#mongodb-expression-exp.-function
2412 */
2413 $function: {
2414 /**
2415 * The function definition. You can specify the function definition as either BSON type Code or String.
2416 */
2417 body: CodeExpression;
2418 /**
2419 * Arguments passed to the function body. If the body function does not take an argument, you can specify an
2420 * empty array [ ]
2421 */
2422 args: ArrayExpression;
2423 /**
2424 * The language used in the body. You must specify lang: "js".
2425 */
2426 lang: 'js'
2427 };
2428 }
2429 }
2430
2431 type Path = string;
2432
2433
2434 export type Expression =
2435 Path |
2436 ArithmeticExpressionOperator |
2437 ArrayExpressionOperator |
2438 BooleanExpressionOperator |
2439 ComparisonExpressionOperator |
2440 ConditionalExpressionOperator |
2441 CustomAggregationExpressionOperator |
2442 DataSizeOperator |
2443 DateExpressionOperator |
2444 LiteralExpressionOperator |
2445 MiscellaneousExpressionOperator |
2446 ObjectExpressionOperator |
2447 SetExpressionOperator |
2448 StringExpressionOperator |
2449 TextExpressionOperator |
2450 TrigonometryExpressionOperator |
2451 TypeExpressionOperator |
2452 AccumulatorOperator |
2453 VariableExpressionOperator |
2454 WindowOperator |
2455 Expression.Top |
2456 Expression.TopN |
2457 any;
2458
2459 export type NullExpression = null;
2460
2461 export type CodeExpression =
2462 string |
2463 Function;
2464
2465 export type BinaryExpression =
2466 Path;
2467
2468 export type FunctionExpression =
2469 Expression.Function;
2470
2471 export type AnyExpression =
2472 ArrayExpression |
2473 BooleanExpression |
2474 NumberExpression |
2475 ObjectExpression |
2476 StringExpression |
2477 DateExpression |
2478 BinaryExpression |
2479 FunctionExpression |
2480 ObjectIdExpression |
2481 ConditionalExpressionOperator |
2482 any;
2483
2484 export type ObjectIdExpression =
2485 TypeExpressionOperatorReturningObjectId;
2486
2487 export type ArrayExpression<T = any> =
2488 T[] |
2489 Path |
2490 ArrayExpressionOperatorReturningAny |
2491 ArrayExpressionOperatorReturningArray |
2492 StringExpressionOperatorReturningArray |
2493 ObjectExpressionOperatorReturningArray |
2494 SetExpressionOperatorReturningArray |
2495 LiteralExpressionOperatorReturningAny |
2496 WindowOperatorReturningArray |
2497 CustomAggregationExpressionOperatorReturningAny |
2498 WindowOperatorReturningAny;
2499
2500 export type BooleanExpression =
2501 boolean |
2502 Path |
2503 BooleanExpressionOperator |
2504 ArrayExpressionOperatorReturningAny |
2505 ComparisonExpressionOperatorReturningBoolean |
2506 StringExpressionOperatorReturningBoolean |
2507 SetExpressionOperatorReturningBoolean |
2508 LiteralExpressionOperatorReturningAny |
2509 CustomAggregationExpressionOperatorReturningAny |
2510 TypeExpressionOperatorReturningBoolean;
2511
2512 export type NumberExpression =
2513 number |
2514 Path |
2515 ArrayExpressionOperatorReturningAny |
2516 ArrayExpressionOperatorReturningNumber |
2517 ArithmeticExpressionOperator |
2518 ComparisonExpressionOperatorReturningNumber |
2519 TrigonometryExpressionOperator |
2520 MiscellaneousExpressionOperatorReturningNumber |
2521 StringExpressionOperatorReturningNumber |
2522 LiteralExpressionOperatorReturningAny |
2523 ObjectExpressionOperator |
2524 SetExpressionOperator |
2525 WindowOperatorReturningNumber |
2526 WindowOperatorReturningAny |
2527 DataSizeOperatorReturningNumber |
2528 CustomAggregationExpressionOperatorReturningAny |
2529 TypeExpressionOperatorReturningNumber |
2530 DateExpression |
2531 DateExpressionOperatorReturningNumber;
2532
2533 export type ObjectExpression =
2534 Path |
2535 ArrayExpressionOperatorReturningAny |
2536 DateExpressionOperatorReturningObject |
2537 StringExpressionOperatorReturningObject |
2538 ObjectExpressionOperatorReturningObject |
2539 CustomAggregationExpressionOperatorReturningAny |
2540 LiteralExpressionOperatorReturningAny;
2541
2542 export type StringExpression<T = string> =
2543 Path |
2544 ArrayExpressionOperatorReturningAny |
2545 DateExpressionOperatorReturningString |
2546 StringExpressionOperatorReturningString |
2547 LiteralExpressionReturningAny |
2548 CustomAggregationExpressionOperatorReturningAny |
2549 TypeExpressionOperatorReturningString |
2550 T;
2551
2552 export type DateExpression =
2553 Path |
2554 NativeDate |
2555 DateExpressionOperatorReturningDate |
2556 TypeExpressionOperatorReturningDate |
2557 LiteralExpressionReturningAny;
2558
2559 export type ArithmeticExpressionOperator =
2560 Expression.Abs |
2561 Expression.Add |
2562 Expression.Ceil |
2563 Expression.Divide |
2564 Expression.Exp |
2565 Expression.Floor |
2566 Expression.Ln |
2567 Expression.Log |
2568 Expression.Log10 |
2569 Expression.Mod |
2570 Expression.Multiply |
2571 Expression.Pow |
2572 Expression.Round |
2573 Expression.Sqrt |
2574 Expression.Subtract |
2575 Expression.Trunc;
2576
2577 export type ArrayExpressionOperator =
2578 ArrayExpressionOperatorReturningAny |
2579 ArrayExpressionOperatorReturningBoolean |
2580 ArrayExpressionOperatorReturningNumber |
2581 ArrayExpressionOperatorReturningObject;
2582
2583 export type LiteralExpressionOperator =
2584 Expression.Literal;
2585
2586 export type LiteralExpressionReturningAny =
2587 LiteralExpressionOperatorReturningAny;
2588
2589 export type LiteralExpressionOperatorReturningAny =
2590 Expression.Literal;
2591
2592 export type MiscellaneousExpressionOperator =
2593 Expression.Rand |
2594 Expression.SampleRate;
2595
2596 export type MiscellaneousExpressionOperatorReturningNumber =
2597 Expression.Rand;
2598
2599 export type ArrayExpressionOperatorReturningAny =
2600 Expression.ArrayElemAt |
2601 Expression.First |
2602 Expression.Last |
2603 Expression.Reduce;
2604
2605 export type ArrayExpressionOperatorReturningArray =
2606 Expression.ConcatArrays |
2607 Expression.Filter |
2608 Expression.Map |
2609 Expression.ObjectToArray |
2610 Expression.Range |
2611 Expression.ReverseArray |
2612 Expression.Slice |
2613 Expression.Zip;
2614
2615 export type ArrayExpressionOperatorReturningNumber =
2616 Expression.IndexOfArray |
2617 Expression.Size;
2618
2619 export type ArrayExpressionOperatorReturningObject =
2620 Expression.ArrayToObject;
2621
2622 export type ArrayExpressionOperatorReturningBoolean =
2623 Expression.In |
2624 Expression.IsArray;
2625
2626 export type BooleanExpressionOperator =
2627 Expression.And |
2628 Expression.Or |
2629 Expression.Not;
2630
2631 export type ComparisonExpressionOperator =
2632 ComparisonExpressionOperatorReturningBoolean |
2633 ComparisonExpressionOperatorReturningNumber;
2634
2635 export type ComparisonExpressionOperatorReturningBoolean =
2636 Expression.Eq |
2637 Expression.Gt |
2638 Expression.Gte |
2639 Expression.Lt |
2640 Expression.Lte |
2641 Expression.Ne;
2642
2643 export type ComparisonExpressionOperatorReturningNumber =
2644 Expression.Cmp;
2645
2646 export type ConditionalExpressionOperator =
2647 Expression.Cond |
2648 Expression.IfNull |
2649 Expression.Switch;
2650
2651 export type StringExpressionOperator =
2652 StringExpressionOperatorReturningArray |
2653 StringExpressionOperatorReturningBoolean |
2654 StringExpressionOperatorReturningNumber |
2655 StringExpressionOperatorReturningObject |
2656 StringExpressionOperatorReturningString;
2657
2658 export type StringExpressionOperatorReturningArray =
2659 Expression.RegexFindAll |
2660 Expression.Split;
2661
2662 export type StringExpressionOperatorReturningBoolean =
2663 Expression.RegexMatch;
2664
2665 export type StringExpressionOperatorReturningNumber =
2666 Expression.IndexOfBytes |
2667 Expression.IndexOfCP |
2668 Expression.Strcasecmp |
2669 Expression.StrLenBytes |
2670 Expression.StrLenCP;
2671
2672 export type StringExpressionOperatorReturningObject =
2673 Expression.RegexFind;
2674
2675 export type StringExpressionOperatorReturningString =
2676 Expression.Concat |
2677 Expression.Ltrim |
2678 Expression.Ltrim |
2679 Expression.ReplaceOne |
2680 Expression.ReplaceAll |
2681 Expression.Substr |
2682 Expression.SubstrBytes |
2683 Expression.SubstrCP |
2684 Expression.ToLower |
2685 Expression.ToString |
2686 Expression.ToUpper |
2687 Expression.Trim;
2688
2689 export type ObjectExpressionOperator =
2690 Expression.MergeObjects |
2691 Expression.ObjectToArray |
2692 Expression.SetField |
2693 Expression.UnsetField;
2694
2695 export type ObjectExpressionOperatorReturningArray =
2696 Expression.ObjectToArray;
2697
2698 export type ObjectExpressionOperatorReturningObject =
2699 Expression.MergeObjects |
2700 Expression.SetField |
2701 Expression.UnsetField;
2702
2703 export type VariableExpressionOperator =
2704 Expression.Let;
2705
2706 export type VariableExpressionOperatorReturningAny =
2707 Expression.Let;
2708
2709 export type SetExpressionOperator =
2710 Expression.AllElementsTrue |
2711 Expression.AnyElementsTrue |
2712 Expression.SetDifference |
2713 Expression.SetEquals |
2714 Expression.SetIntersection |
2715 Expression.SetIsSubset |
2716 Expression.SetUnion;
2717
2718 export type SetExpressionOperatorReturningBoolean =
2719 Expression.AllElementsTrue |
2720 Expression.AnyElementsTrue |
2721 Expression.SetEquals |
2722 Expression.SetIsSubset;
2723
2724 export type SetExpressionOperatorReturningArray =
2725 Expression.SetDifference |
2726 Expression.SetIntersection |
2727 Expression.SetUnion;
2728
2729 /**
2730 * Trigonometry expressions perform trigonometric operations on numbers.
2731 * Values that represent angles are always input or output in radians.
2732 * Use $degreesToRadians and $radiansToDegrees to convert between degree
2733 * and radian measurements.
2734 */
2735 export type TrigonometryExpressionOperator =
2736 Expression.Sin |
2737 Expression.Cos |
2738 Expression.Tan |
2739 Expression.Asin |
2740 Expression.Acos |
2741 Expression.Atan |
2742 Expression.Atan2 |
2743 Expression.Asinh |
2744 Expression.Acosh |
2745 Expression.Atanh |
2746 Expression.Sinh |
2747 Expression.Cosh |
2748 Expression.Tanh |
2749 Expression.DegreesToRadians |
2750 Expression.RadiansToDegrees;
2751
2752 export type TextExpressionOperator =
2753 Expression.Meta;
2754
2755 export type WindowOperator =
2756 Expression.AddToSet |
2757 Expression.Avg |
2758 Expression.Count |
2759 Expression.CovariancePop |
2760 Expression.CovarianceSamp |
2761 Expression.DenseRank |
2762 Expression.Derivative |
2763 Expression.DocumentNumber |
2764 Expression.ExpMovingAvg |
2765 Expression.First |
2766 Expression.Integral |
2767 Expression.Last |
2768 Expression.LinearFill |
2769 Expression.Locf |
2770 Expression.Max |
2771 Expression.Min |
2772 Expression.Push |
2773 Expression.Rank |
2774 Expression.Shift |
2775 Expression.StdDevPop |
2776 Expression.StdDevSamp |
2777 Expression.Sum;
2778
2779 export type WindowOperatorReturningAny =
2780 Expression.First |
2781 Expression.Last |
2782 Expression.Shift;
2783
2784 export type WindowOperatorReturningArray =
2785 Expression.AddToSet |
2786 Expression.Push;
2787
2788 export type WindowOperatorReturningNumber =
2789 Expression.Avg |
2790 Expression.Count |
2791 Expression.CovariancePop |
2792 Expression.CovarianceSamp |
2793 Expression.DenseRank |
2794 Expression.DocumentNumber |
2795 Expression.ExpMovingAvg |
2796 Expression.Integral |
2797 Expression.Max |
2798 Expression.Min |
2799 Expression.StdDevPop |
2800 Expression.StdDevSamp |
2801 Expression.Sum;
2802
2803 export type TypeExpressionOperator =
2804 Expression.Convert |
2805 Expression.IsNumber |
2806 Expression.ToBool |
2807 Expression.ToDate |
2808 Expression.ToDecimal |
2809 Expression.ToDouble |
2810 Expression.ToInt |
2811 Expression.ToLong |
2812 Expression.ToObjectId |
2813 Expression.ToString |
2814 Expression.Type;
2815
2816 export type TypeExpressionOperatorReturningNumber =
2817 Expression.Convert<'double' | 1 | 'int' | 16 | 'long' | 18 | 'decimal' | 19> |
2818 Expression.ToDecimal |
2819 Expression.ToDouble |
2820 Expression.ToInt |
2821 Expression.ToLong;
2822
2823 export type TypeExpressionOperatorReturningBoolean =
2824 Expression.Convert<'bool' | 8> |
2825 Expression.IsNumber |
2826 Expression.ToBool;
2827
2828
2829 export type TypeExpressionOperatorReturningString =
2830 Expression.Convert<'string' | 2> |
2831 Expression.ToString |
2832 Expression.Type;
2833
2834 export type TypeExpressionOperatorReturningObjectId =
2835 Expression.Convert<'objectId' | 7> |
2836 Expression.ToObjectId;
2837
2838 export type TypeExpressionOperatorReturningDate =
2839 Expression.Convert<'date' | 9> |
2840 Expression.ToDate;
2841
2842 export type DataSizeOperator =
2843 Expression.BinarySize |
2844 Expression.BsonSize;
2845
2846 export type DataSizeOperatorReturningNumber =
2847 Expression.BinarySize |
2848 Expression.BsonSize;
2849
2850 export type CustomAggregationExpressionOperator =
2851 Expression.Accumulator |
2852 Expression.Function;
2853
2854 export type CustomAggregationExpressionOperatorReturningAny =
2855 Expression.Function;
2856
2857 export type AccumulatorOperator =
2858 Expression.Accumulator |
2859 Expression.AddToSet |
2860 Expression.Avg |
2861 Expression.Count |
2862 Expression.First |
2863 Expression.Last |
2864 Expression.Max |
2865 Expression.MergeObjects |
2866 Expression.Min |
2867 Expression.Push |
2868 Expression.StdDevPop |
2869 Expression.StdDevSamp |
2870 Expression.Sum |
2871 Expression.Top |
2872 Expression.TopN;
2873
2874 export type tzExpression = UTCOffset | StringExpressionOperatorReturningBoolean | string;
2875
2876 type hh = '-00' | '-01' | '-02' | '-03' | '-04' | '-05' | '-06' | '-07' | '-08' | '-09' | '-10' | '-11' | '-12' |
2877 '+00' | '+01' | '+02' | '+03' | '+04' | '+05' | '+06' | '+07' | '+08' | '+09' | '+10' | '+11' | '+12' | '+13' | '+14';
2878 type mm = '00' | '30' | '45';
2879
2880 type UTCOffset = `${hh}` | `${hh}${mm}` | `${hh}:${mm}`;
2881
2882 type RegexOptions =
2883 'i' | 'm' | 's' | 'x' |
2884 'is' | 'im' | 'ix' | 'si' | 'sm' | 'sx' | 'mi' | 'ms' | 'mx' | 'xi' | 'xs' | 'xm' |
2885 'ism' | 'isx' | 'ims' | 'imx' | 'ixs' | 'ixm' | 'sim' | 'six' | 'smi' | 'smx' | 'sxi' | 'sxm' | 'mis' | 'mix' | 'msi' | 'msx' | 'mxi' | 'mxs' | 'xis' | 'xim' | 'xsi' | 'xsm' | 'xmi' | 'xms' |
2886 'ismx' | 'isxm' | 'imsx' | 'imxs' | 'ixsm' | 'ixms' | 'simx' | 'sixm' | 'smix' | 'smxi' | 'sxim' | 'sxmi' | 'misx' | 'mixs' | 'msix' | 'msxi' | 'mxis' | 'mxsi' | 'xism' | 'xims' | 'xsim' | 'xsmi' | 'xmis' | 'xmsi';
2887
2888 type StartOfWeek =
2889 'monday' | 'mon' |
2890 'tuesday' | 'tue' |
2891 'wednesday' | 'wed' |
2892 'thursday' | 'thu' |
2893 'friday' | 'fri' |
2894 'saturday' | 'sat' |
2895 'sunday' | 'sun';
2896
2897 type DateUnit = 'year' | 'quarter' | 'week' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond';
2898
2899 type FormatString = string;
2900
2901 export type DateExpressionOperator =
2902 DateExpressionOperatorReturningDate |
2903 DateExpressionOperatorReturningNumber |
2904 DateExpressionOperatorReturningString |
2905 DateExpressionOperatorReturningObject;
2906
2907 export type DateExpressionOperatorReturningObject =
2908 Expression.DateToParts;
2909
2910 export type DateExpressionOperatorReturningNumber =
2911 Expression.DateDiff |
2912 Expression.DayOfMonth |
2913 Expression.DayOfWeek |
2914 Expression.DayOfYear |
2915 Expression.IsoDayOfWeek |
2916 Expression.IsoWeek |
2917 Expression.IsoWeekYear |
2918 Expression.Millisecond |
2919 Expression.Second |
2920 Expression.Minute |
2921 Expression.Hour |
2922 Expression.Month |
2923 Expression.Year;
2924
2925 export type DateExpressionOperatorReturningDate =
2926 Expression.DateAdd |
2927 Expression.DateFromParts |
2928 Expression.DateFromString |
2929 Expression.DateSubtract |
2930 Expression.DateTrunc |
2931 Expression.ToDate;
2932
2933 export type DateExpressionOperatorReturningString =
2934 Expression.DateToString;
2935
2936}