UNPKG

111 kBTypeScriptView Raw
1declare module 'mongoose' {
2
3 /**
4 * [Expressions reference](https://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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://docs.mongodb.com/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 }
1132
1133 export interface First {
1134 /**
1135 * Returns the first array element. Distinct from $first accumulator.
1136 *
1137 * @version 5.0
1138 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/first/#mongodb-expression-exp.-first
1139 */
1140 $first: Expression;
1141 }
1142
1143 export interface In {
1144 /**
1145 * Returns a boolean indicating whether a specified value is in an array.
1146 *
1147 * @version 3.4
1148 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/in/#mongodb-expression-exp.-in
1149 */
1150 $in: [Expression, ArrayExpression];
1151 }
1152
1153 export interface IndexOfArray {
1154 /**
1155 * 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.
1156 *
1157 * @version 3.4
1158 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/indexOfArray/#mongodb-expression-exp.-indexOfArray
1159 */
1160 $indexOfArray: [ArrayExpression, Expression] | [ArrayExpression, Expression, NumberExpression] | [ArrayExpression, Expression, NumberExpression, NumberExpression];
1161 }
1162
1163 export interface IsArray {
1164 /**
1165 * Determines if the operand is an array. Returns a boolean.
1166 *
1167 * @version 3.2
1168 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/isArray/#mongodb-expression-exp.-isArray
1169 */
1170 $isArray: [Expression];
1171 }
1172
1173 export interface Last {
1174 /**
1175 * Returns the last array element. Distinct from $last accumulator.
1176 *
1177 * @version 5.0
1178 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/last/#mongodb-expression-exp.-last
1179 */
1180 $last: Expression;
1181 }
1182
1183 export interface Map {
1184 /**
1185 * Applies a subexpression to each element of an array and returns the array of resulting values in order. Accepts named parameters.
1186 *
1187 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/map/#mongodb-expression-exp.-map
1188 */
1189 $map: {
1190 /**
1191 * An expression that resolves to an array.
1192 */
1193 input: ArrayExpression;
1194 /**
1195 * 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.
1196 */
1197 as?: string;
1198 /**
1199 * 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.
1200 */
1201 in: Expression;
1202 };
1203 }
1204
1205 export interface ObjectToArray {
1206 /**
1207 * Converts a document to an array of documents representing key-value pairs.
1208 *
1209 * @version 3.4.4
1210 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/objectToArray/#mongodb-expression-exp.-objectToArray
1211 */
1212 $objectToArray: ObjectExpression;
1213 }
1214
1215 export interface Range {
1216 /**
1217 * Outputs an array containing a sequence of integers according to user-defined inputs.
1218 *
1219 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/range/#mongodb-expression-exp.-range
1220 */
1221 $range: [NumberExpression, NumberExpression] | [NumberExpression, NumberExpression, NumberExpression];
1222 }
1223
1224 export interface Reduce {
1225 /**
1226 * Applies an expression to each element in an array and combines them into a single value.
1227 *
1228 * @version 3.4
1229 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/reduce/#mongodb-expression-exp.-reduce
1230 */
1231 $reduce: {
1232 /**
1233 * Can be any valid expression that resolves to an array. For more information on expressions, see Expressions.
1234 *
1235 * If the argument resolves to a value of null or refers to a missing field, $reduce returns null.
1236 *
1237 * If the argument does not resolve to an array or null nor refers to a missing field, $reduce returns an error.
1238 */
1239 input: ArrayExpression;
1240 /**
1241 * The initial cumulative value set before in is applied to the first element of the input array.
1242 */
1243 initialValue: Expression;
1244 /**
1245 * 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.
1246 *
1247 * During evaluation of the in expression, two variables will be available:
1248 * - `value` is the variable that represents the cumulative value of the expression.
1249 * - `this` is the variable that refers to the element being processed.
1250 */
1251 in: Expression;
1252 };
1253 }
1254
1255 export interface ReverseArray {
1256 /**
1257 * Returns an array with the elements in reverse order.
1258 *
1259 * @version 3.4
1260 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/reverseArray/#mongodb-expression-exp.-reverseArray
1261 */
1262 $reverseArray: ArrayExpression;
1263 }
1264
1265 export interface Size {
1266 /**
1267 * Returns the number of elements in the array. Accepts a single expression as argument.
1268 *
1269 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/size/#mongodb-expression-exp.-size
1270 */
1271 $size: ArrayExpression;
1272 }
1273
1274 export interface Slice {
1275 /**
1276 * Returns a subset of an array.
1277 *
1278 * @version 3.2
1279 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/slice/#mongodb-expression-exp.-slice
1280 */
1281 $slice: [ArrayExpression, NumberExpression] | [ArrayExpression, NumberExpression, NumberExpression];
1282 }
1283
1284 export interface Zip {
1285 /**
1286 * Merge two arrays together.
1287 *
1288 * @version 3.4
1289 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/zip/#mongodb-expression-exp.-zip
1290 */
1291 $zip: {
1292 /**
1293 * An array of expressions that resolve to arrays. The elements of these input arrays combine to form the arrays of the output array.
1294 *
1295 * If any of the inputs arrays resolves to a value of null or refers to a missing field, $zip returns null.
1296 *
1297 * If any of the inputs arrays does not resolve to an array or null nor refers to a missing field, $zip returns an error.
1298 */
1299 inputs: ArrayExpression[];
1300 /**
1301 * A boolean which specifies whether the length of the longest array determines the number of arrays in the output array.
1302 *
1303 * The default value is false: the shortest array length determines the number of arrays in the output array.
1304 */
1305 useLongestLength?: boolean;
1306 /**
1307 * 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.
1308 *
1309 * If useLongestLength: true but defaults is empty or not specified, $zip uses null as the default value.
1310 *
1311 * If specifying a non-empty defaults, you must specify a default for each input array or else $zip will return an error.
1312 */
1313 defaults?: ArrayExpression;
1314 };
1315 }
1316
1317 export interface Concat {
1318 /**
1319 * Concatenates any number of strings.
1320 *
1321 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/concat/#mongodb-expression-exp.-concat
1322 */
1323 $concat: StringExpression[];
1324 }
1325
1326 export interface IndexOfBytes {
1327 /**
1328 * 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.
1329 *
1330 * @version 3.4
1331 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/indexOfBytes/#mongodb-expression-exp.-indexOfBytes
1332 */
1333 $indexOfBytes: [StringExpression, StringExpression] | [StringExpression, StringExpression, NumberExpression] | [StringExpression, StringExpression, NumberExpression, NumberExpression];
1334 }
1335
1336 export interface IndexOfCP {
1337 /**
1338 * 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
1339 *
1340 * @version 3.4
1341 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/indexOfCP/#mongodb-expression-exp.-indexOfCP
1342 */
1343 $indexOfCP: [StringExpression, StringExpression] | [StringExpression, StringExpression, NumberExpression] | [StringExpression, StringExpression, NumberExpression, NumberExpression];
1344 }
1345
1346 export interface Ltrim {
1347 /**
1348 * Removes whitespace or the specified characters from the beginning of a string.
1349 *
1350 * @version 4.0
1351 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/ltrim/#mongodb-expression-exp.-ltrim
1352 */
1353 $ltrim: {
1354 /**
1355 * The string to trim. The argument can be any valid expression that resolves to a string. For more information on expressions, see Expressions.
1356 */
1357 input: StringExpression;
1358 /**
1359 * The character(s) to trim from the beginning of the input.
1360 *
1361 * 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.
1362 *
1363 * If unspecified, $ltrim removes whitespace characters, including the null character. For the list of whitespace characters, see Whitespace Characters.
1364 */
1365 chars?: StringExpression;
1366 };
1367 }
1368
1369 export interface RegexFind {
1370 /**
1371 * Applies a regular expression (regex) to a string and returns information on the first matched substring.
1372 *
1373 * @version 4.2
1374 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/regexFind/#mongodb-expression-exp.-regexFind
1375 */
1376 $regexFind: {
1377 /**
1378 * The string on which you wish to apply the regex pattern. Can be a string or any valid expression that resolves to a string.
1379 */
1380 input: Expression; // TODO: Resolving to string, which ones?
1381 /**
1382 * 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):
1383 * - "pattern"
1384 * - /pattern/
1385 * - /pattern/options
1386 *
1387 * 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.
1388 *
1389 * You cannot specify options in both the regex and the options field.
1390 */
1391 regex: RegExp | string;
1392 /**
1393 * The following <options> are available for use with regular expression.
1394 *
1395 * Note: You cannot specify options in both the regex and the options field.
1396 *
1397 * Option Description
1398 *
1399 * `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.
1400 *
1401 * `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.
1402 * If the pattern contains no anchors or if the string value has no newline characters (e.g. \n), the m option has no effect.
1403 *
1404 * `x` "Extended" capability to ignore all white space characters in the pattern unless escaped or included in a character class.
1405 * 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.
1406 * The x option does not affect the handling of the VT character (i.e. code 11).
1407 * You can specify the option only in the options field.
1408 *
1409 * `s` Allows the dot character (i.e. .) to match all characters including newline characters.
1410 * You can specify the option only in the options field.
1411 */
1412 options?: RegexOptions;
1413 };
1414 }
1415
1416 export interface RegexFindAll {
1417 /**
1418 * Applies a regular expression (regex) to a string and returns information on the all matched substrings.
1419 *
1420 * @version 4.2
1421 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/regexFindAll/#mongodb-expression-exp.-regexFindAll
1422 */
1423 $regexFindAll: {
1424 /**
1425 * The string on which you wish to apply the regex pattern. Can be a string or any valid expression that resolves to a string.
1426 */
1427 input: Expression; // TODO: Resolving to string, which ones?
1428 /**
1429 * 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):
1430 * - "pattern"
1431 * - /pattern/
1432 * - /pattern/options
1433 *
1434 * 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.
1435 *
1436 * You cannot specify options in both the regex and the options field.
1437 */
1438 regex: RegExp | string;
1439 /**
1440 * The following <options> are available for use with regular expression.
1441 *
1442 * Note: You cannot specify options in both the regex and the options field.
1443 *
1444 * Option Description
1445 *
1446 * `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.
1447 *
1448 * `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.
1449 * If the pattern contains no anchors or if the string value has no newline characters (e.g. \n), the m option has no effect.
1450 *
1451 * `x` "Extended" capability to ignore all white space characters in the pattern unless escaped or included in a character class.
1452 * 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.
1453 * The x option does not affect the handling of the VT character (i.e. code 11).
1454 * You can specify the option only in the options field.
1455 *
1456 * `s` Allows the dot character (i.e. .) to match all characters including newline characters.
1457 * You can specify the option only in the options field.
1458 */
1459 options?: RegexOptions;
1460 };
1461 }
1462
1463 export interface RegexMatch {
1464 /**
1465 * Applies a regular expression (regex) to a string and returns a boolean that indicates if a match is found or not.
1466 *
1467 * @version 4.2
1468 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/regexMatch/#mongodb-expression-exp.-regexMatch
1469 */
1470 $regexMatch: {
1471 /**
1472 * The string on which you wish to apply the regex pattern. Can be a string or any valid expression that resolves to a string.
1473 */
1474 input: Expression; // TODO: Resolving to string, which ones?
1475 /**
1476 * 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):
1477 * - "pattern"
1478 * - /pattern/
1479 * - /pattern/options
1480 *
1481 * 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.
1482 *
1483 * You cannot specify options in both the regex and the options field.
1484 */
1485 regex: RegExp | string;
1486 /**
1487 * The following <options> are available for use with regular expression.
1488 *
1489 * Note: You cannot specify options in both the regex and the options field.
1490 *
1491 * Option Description
1492 *
1493 * `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.
1494 *
1495 * `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.
1496 * If the pattern contains no anchors or if the string value has no newline characters (e.g. \n), the m option has no effect.
1497 *
1498 * `x` "Extended" capability to ignore all white space characters in the pattern unless escaped or included in a character class.
1499 * 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.
1500 * The x option does not affect the handling of the VT character (i.e. code 11).
1501 * You can specify the option only in the options field.
1502 *
1503 * `s` Allows the dot character (i.e. .) to match all characters including newline characters.
1504 * You can specify the option only in the options field.
1505 */
1506 options?: RegexOptions;
1507 };
1508 }
1509
1510 export interface ReplaceOne {
1511 /**
1512 * Replaces the first instance of a matched string in a given input.
1513 *
1514 * @version 4.4
1515 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/replaceOne/#mongodb-expression-exp.-replaceOne
1516 */
1517 $replaceOne: {
1518 /**
1519 * 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.
1520 */
1521 input: StringExpression;
1522 /**
1523 * 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.
1524 */
1525 find: StringExpression;
1526 /**
1527 * 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.
1528 */
1529 replacement: StringExpression;
1530 };
1531 }
1532
1533 export interface ReplaceAll {
1534 /**
1535 * Replaces all instances of a matched string in a given input.
1536 *
1537 * @version 4.4
1538 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/replaceAll/#mongodb-expression-exp.-replaceAll
1539 */
1540 $replaceAll: {
1541 /**
1542 * 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.
1543 */
1544 input: StringExpression;
1545 /**
1546 * 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.
1547 */
1548 find: StringExpression;
1549 /**
1550 * 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.
1551 */
1552 replacement: StringExpression;
1553 };
1554 }
1555
1556 export interface Rtrim {
1557 /**
1558 * Removes whitespace or the specified characters from the end of a string.
1559 *
1560 * @version 4.0
1561 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/rtrim/#mongodb-expression-exp.-rtrim
1562 */
1563 $rtrim: {
1564 /**
1565 * The string to trim. The argument can be any valid expression that resolves to a string. For more information on expressions, see Expressions.
1566 */
1567 input: StringExpression;
1568 /**
1569 * The character(s) to trim from the beginning of the input.
1570 *
1571 * 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.
1572 *
1573 * If unspecified, $rtrim removes whitespace characters, including the null character. For the list of whitespace characters, see Whitespace Characters.
1574 */
1575 chars?: StringExpression;
1576 };
1577 }
1578
1579 export interface Split {
1580 /**
1581 * 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.
1582 *
1583 * @version 3.4
1584 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/split/#mongodb-expression-exp.-split
1585 */
1586 $split: [StringExpression, StringExpression];
1587 }
1588
1589 export interface StrLenBytes {
1590 /**
1591 * Returns the number of UTF-8 encoded bytes in a string.
1592 *
1593 * @version 3.4
1594 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/strLenBytes/#mongodb-expression-exp.-strLenBytes
1595 */
1596 $strLenBytes: StringExpression;
1597 }
1598
1599 export interface StrLenCP {
1600 /**
1601 * Returns the number of UTF-8 code points in a string.
1602 *
1603 * @version 3.4
1604 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/strLenCP/#mongodb-expression-exp.-strLenCP
1605 */
1606 $strLenCP: StringExpression;
1607 }
1608
1609 export interface Strcasecmp {
1610 /**
1611 * 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.
1612 *
1613 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/strcasecmp/#mongodb-expression-exp.-strcasecmp
1614 */
1615 $strcasecmp: [StringExpression, StringExpression];
1616 }
1617
1618 export interface Substr {
1619 /**
1620 * Deprecated. Use $substrBytes or $substrCP.
1621 *
1622 * @deprecated 3.4
1623 * @alias {Expression.SubstrBytes}
1624 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/substr/#mongodb-expression-exp.-substr
1625 */
1626 $substr: [StringExpression, number, number];
1627 }
1628
1629 export interface SubstrBytes {
1630 /**
1631 * 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.
1632 *
1633 * @version 3.4
1634 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/substrBytes/#mongodb-expression-exp.-substrBytes
1635 */
1636 $substrBytes: [StringExpression, number, number];
1637 }
1638
1639 export interface SubstrCP {
1640 /**
1641 * 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.
1642 *
1643 * @version 3.4
1644 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/substrCP/#mongodb-expression-exp.-substrCP
1645 */
1646 $substrCP: [StringExpression, number, number];
1647 }
1648
1649 export interface ToLower {
1650 /**
1651 * Converts a string to lowercase. Accepts a single argument expression.
1652 *
1653 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/toLower/#mongodb-expression-exp.-toLower
1654 */
1655 $toLower: StringExpression;
1656 }
1657
1658 export interface ToString {
1659 /**
1660 * Converts value to a string.
1661 *
1662 * @version 4.0
1663 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/toString/#mongodb-expression-exp.-toString
1664 */
1665 $toString: Expression;
1666 }
1667
1668 export interface Trim {
1669 /**
1670 * Removes whitespace or the specified characters from the beginning and end of a string.
1671 *
1672 * @version 4.0
1673 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/trim/#mongodb-expression-exp.-trim
1674 */
1675 $trim: {
1676 /**
1677 * The string to trim. The argument can be any valid expression that resolves to a string. For more information on expressions, see Expressions.
1678 */
1679 input: StringExpression;
1680 /**
1681 * The character(s) to trim from the beginning of the input.
1682 *
1683 * 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.
1684 *
1685 * If unspecified, $trim removes whitespace characters, including the null character. For the list of whitespace characters, see Whitespace Characters.
1686 */
1687 chars?: StringExpression;
1688 };
1689 }
1690
1691 export interface ToUpper {
1692 /**
1693 * Converts a string to uppercase. Accepts a single argument expression.
1694 *
1695 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/toUpper/#mongodb-expression-exp.-toUpper
1696 */
1697 $toUpper: StringExpression;
1698 }
1699
1700 export interface Literal {
1701
1702 /**
1703 * Returns a value without parsing. Use for values that the aggregation pipeline may interpret as an
1704 * expression.
1705 *
1706 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/literal/#mongodb-expression-exp.-literal
1707 */
1708 $literal: any;
1709 }
1710
1711 export interface GetField {
1712
1713 /**
1714 * Returns the value of a specified field from a document. If you don't specify an object, $getField returns
1715 * the value of the field from $$CURRENT.
1716 *
1717 * @version 4.4.2
1718 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/getField/#mongodb-expression-exp.-getField
1719 */
1720 $getField: {
1721 /**
1722 * Field in the input object for which you want to return a value. field can be any valid expression that
1723 * resolves to a string constant.
1724 */
1725 field: StringExpression;
1726 /**
1727 * A valid expression that contains the field for which you want to return a value. input must resolve to an
1728 * object, missing, null, or undefined. If omitted, defaults to the document currently being processed in the
1729 * pipeline ($$CURRENT).
1730 */
1731 input?: ObjectExpression | SpecialPathVariables | NullExpression;
1732 }
1733 }
1734
1735 export interface Rand {
1736
1737 /**
1738 * Returns a random float between 0 and 1 each time it is called.
1739 *
1740 * @version 4.4.2
1741 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/rand/#mongodb-expression-exp.-rand
1742 */
1743 $rand: Record<string | number | symbol, never>;
1744 }
1745
1746 export interface SampleRate {
1747
1748 /**
1749 * Matches a random selection of input documents. The number of documents selected approximates the sample
1750 * rate expressed as a percentage of the total number of documents.
1751 *
1752 * @version 4.4.2
1753 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/sampleRate/#mongodb-expression-exp.-sampleRate
1754 */
1755 $sampleRate: number;
1756 }
1757
1758 export interface MergeObjects {
1759
1760 /**
1761 * Combines multiple documents into a single document.
1762 *
1763 * @version 3.6
1764 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/mergeObjects/#mongodb-expression-exp.-mergeObjects
1765 */
1766 $mergeObjects: ObjectExpression | ObjectExpression[] | ArrayExpression;
1767 }
1768
1769 export interface SetField {
1770
1771 /**
1772 * Adds, updates, or removes a specified field in a document.
1773 *
1774 * @version 5.0
1775 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/setField/#mongodb-expression-exp.-setField
1776 */
1777 $setField: {
1778 /**
1779 * Field in the input object that you want to add, update, or remove. field can be any valid expression that
1780 * resolves to a string constant.
1781 */
1782 field: StringExpression;
1783 /**
1784 * Document that contains the field that you want to add or update. input must resolve to an object, missing,
1785 * null, or undefined
1786 */
1787 input?: ObjectExpression | NullExpression;
1788 /**
1789 * The value that you want to assign to field. value can be any valid expression.
1790 */
1791 value?: Expression | SpecialPathVariables;
1792 }
1793 }
1794
1795 export interface UnsetField {
1796
1797 /**
1798 * Removes a specified field in a document.
1799 *
1800 * @version 5.0
1801 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/unsetField/#mongodb-expression-exp.-unsetField
1802 */
1803 $unsetField: {
1804 /**
1805 * Field in the input object that you want to add, update, or remove. field can be any valid expression that
1806 * resolves to a string constant.
1807 */
1808 field: StringExpression;
1809 /**
1810 * Document that contains the field that you want to add or update. input must resolve to an object, missing,
1811 * null, or undefined.
1812 */
1813 input?: ObjectExpression | SpecialPathVariables | NullExpression;
1814 }
1815 }
1816
1817 export interface Let {
1818
1819 /**
1820 * Binds variables for use in the specified expression, and returns the result of the expression.
1821 *
1822 * @version 5.0
1823 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/let/#mongodb-expression-exp.-let
1824 */
1825 $let: {
1826 /**
1827 * Assignment block for the variables accessible in the in expression. To assign a variable, specify a
1828 * string for the variable name and assign a valid expression for the value.
1829 */
1830 vars: { [key: string]: Expression; };
1831 /**
1832 * The expression to evaluate.
1833 */
1834 in: Expression;
1835 }
1836 }
1837
1838 export interface AllElementsTrue {
1839 /**
1840 * Evaluates an array as a set and returns true if no element in the array is false. Otherwise, returns false. An
1841 * empty array returns true.
1842 *
1843 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/allElementsTrue/#mongodb-expression-exp.-allElementsTrue
1844 */
1845 $allElementsTrue: ArrayExpression;
1846 }
1847
1848 export interface AnyElementsTrue {
1849 /**
1850 * Evaluates an array as a set and returns true if any of the elements are true and false otherwise. An empty
1851 * array returns false.
1852 *
1853 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/anyElementsTrue/#mongodb-expression-exp.-anyElementsTrue
1854 */
1855 $anyElementTrue: ArrayExpression;
1856 }
1857
1858 export interface SetDifference {
1859 /**
1860 * Takes two sets and returns an array containing the elements that only exist in the first set; i.e. performs a
1861 * relative complement of the second set relative to the first.
1862 *
1863 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/setDifference/#mongodb-expression-exp.-setDifference
1864 */
1865 $setDifference: [ArrayExpression, ArrayExpression];
1866 }
1867
1868 export interface SetEquals {
1869 /**
1870 * Compares two or more arrays and returns true if they have the same distinct elements and false otherwise.
1871 *
1872 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/setEquals/#mongodb-expression-exp.-setEquals
1873 */
1874 $setEquals: ArrayExpression[];
1875 }
1876
1877 export interface SetIntersection {
1878 /**
1879 * Takes two or more arrays and returns an array that contains the elements that appear in every input array.
1880 *
1881 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/setIntersection/#mongodb-expression-exp.-setIntersection
1882 */
1883 $setIntersection: ArrayExpression[];
1884 }
1885
1886 export interface SetIsSubset {
1887 /**
1888 * Takes two arrays and returns true when the first array is a subset of the second, including when the first
1889 * array equals the second array, and false otherwise.
1890 *
1891 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/setIsSubset/#mongodb-expression-exp.-setIsSubset
1892 */
1893 $setIsSubset: [ArrayExpression, ArrayExpression];
1894 }
1895
1896 export interface SetUnion {
1897 /**
1898 * Takes two or more arrays and returns an array containing the elements that appear in any input array.
1899 *
1900 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/setUnion/#mongodb-expression-exp.-setUnion
1901 */
1902 $setUnion: ArrayExpression[];
1903 }
1904
1905 export interface Accumulator {
1906 /**
1907 * Defines a custom accumulator operator. Accumulators are operators that maintain their state (e.g. totals,
1908 * maximums, minimums, and related data) as documents progress through the pipeline. Use the $accumulator operator
1909 * to execute your own JavaScript functions to implement behavior not supported by the MongoDB Query Language. See
1910 * also $function.
1911 *
1912 * @version 4.4
1913 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/accumulator/#mongodb-expression-exp.-accumulator
1914 */
1915 $accumulator: {
1916 /**
1917 * Function used to initialize the state. The init function receives its arguments from the initArgs array
1918 * expression. You can specify the function definition as either BSON type Code or String.
1919 */
1920 init: CodeExpression;
1921 /**
1922 * Arguments passed to the init function.
1923 */
1924 initArgs?: ArrayExpression;
1925 /**
1926 * Function used to accumulate documents. The accumulate function receives its arguments from the current state
1927 * and accumulateArgs array expression. The result of the accumulate function becomes the new state. You can
1928 * specify the function definition as either BSON type Code or String.
1929 */
1930 accumulate: CodeExpression;
1931 /**
1932 * Arguments passed to the accumulate function. You can use accumulateArgs to specify what field value(s) to
1933 * pass to the accumulate function.
1934 */
1935 accumulateArgs: ArrayExpression;
1936 /**
1937 * Function used to merge two internal states. merge must be either a String or Code BSON type. merge returns
1938 * the combined result of the two merged states. For information on when the merge function is called, see Merge
1939 * Two States with $merge.
1940 */
1941 merge: CodeExpression;
1942 /**
1943 * Function used to update the result of the accumulation.
1944 */
1945 finalize?: CodeExpression;
1946 /**
1947 * The language used in the $accumulator code.
1948 */
1949 lang: 'js';
1950 }
1951 }
1952
1953 export interface AddToSet {
1954 /**
1955 * Returns an array of all unique values that results from applying an expression to each document in a group.
1956 *
1957 * @version 5.0
1958 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/addToSet/#mongodb-expression-exp.-addToSet
1959 */
1960 $addToSet: Expression | Record<string, Expression>;
1961 }
1962
1963 export interface Avg {
1964 /**
1965 * Returns the average value of the numeric values. $avg ignores non-numeric values.
1966 *
1967 * @version 5.0
1968 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/avg/#mongodb-expression-exp.-avg
1969 */
1970 $avg: Expression;
1971 }
1972
1973 export interface Count {
1974 /**
1975 * Returns the number of documents in a group.
1976 *
1977 * @version 5.0
1978 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/count/#mongodb-expression-exp.-count
1979 */
1980 $count: Record<string | number | symbol, never> | Path;
1981 }
1982
1983 export interface CovariancePop {
1984 /**
1985 * Returns the population covariance of two numeric expressions that are evaluated using documents in the
1986 * $setWindowFields stage window.
1987 *
1988 * @version 5.0
1989 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/covariancePop/#mongodb-expression-exp.-covariancePop
1990 */
1991 $covariancePop: [NumberExpression, NumberExpression];
1992 }
1993
1994 export interface CovarianceSamp {
1995 /**
1996 * Returns the sample covariance of two numeric expressions that are evaluated using documents in the
1997 * $setWindowFields stage window.
1998 *
1999 * @version 5.0
2000 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/covarianceSamp/#mongodb-expression-exp.-covarianceSamp
2001 */
2002 $covarianceSamp: [NumberExpression, NumberExpression];
2003 }
2004
2005 export interface DenseRank {
2006 /**
2007 * Returns the document position (known as the rank) relative to other documents in the $setWindowFields stage
2008 * partition.
2009 *
2010 * @version 5.0
2011 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/denseRank/#mongodb-expression-exp.-denseRank
2012 */
2013 $denseRank: Record<string | number | symbol, never>;
2014 }
2015
2016 export interface Derivative {
2017 /**
2018 * Returns the average rate of change within the specified window, which is calculated using the:
2019 *
2020 * @version 5.0
2021 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/derivative/#mongodb-expression-exp.-derivative
2022 */
2023 $derivative: {
2024 /**
2025 * Specifies the expression to evaluate. The expression must evaluate to a number.
2026 */
2027 input: NumberExpression;
2028 /**
2029 * A string that specifies the time unit.
2030 */
2031 unit?: DateUnit;
2032 }
2033 }
2034
2035 export interface DocumentNumber {
2036 /**
2037 * Returns the position of a document (known as the document number) in the $setWindowFields stage partition.
2038 *
2039 * @version 5.0
2040 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/documentNumber/#mongodb-expression-exp.-documentNumber
2041 */
2042 $documentNumber: Record<string | number | symbol, never>;
2043 }
2044
2045 export interface ExpMovingAvg {
2046 /**
2047 * Returns the exponential moving average of numeric expressions applied to documents in a partition defined in
2048 * the $setWindowFields stage.
2049 *
2050 * @version 5.0
2051 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/expMovingAvg/#mongodb-expression-exp.-expMovingAvg
2052 */
2053 $expMovingAvg: {
2054 /**
2055 * Specifies the expression to evaluate. Non-numeric expressions are ignored.
2056 */
2057 input: Expression;
2058
2059 /**
2060 * An integer that specifies the number of historical documents that have a significant mathematical weight in
2061 * the exponential moving average calculation, with the most recent documents contributing the most weight.
2062 *
2063 * You must specify either N or alpha. You cannot specify both.
2064 */
2065 N: NumberExpression;
2066
2067 /**
2068 * A double that specifies the exponential decay value to use in the exponential moving average calculation. A
2069 * higher alpha value assigns a lower mathematical significance to previous results from the calculation.
2070 *
2071 * You must specify either N or alpha. You cannot specify both.
2072 */
2073 alpha?: never;
2074 } |
2075 {
2076 /**
2077 * Specifies the expression to evaluate. Non-numeric expressions are ignored.
2078 */
2079 input: Expression;
2080
2081 /**
2082 * An integer that specifies the number of historical documents that have a significant mathematical weight in
2083 * the exponential moving average calculation, with the most recent documents contributing the most weight.
2084 *
2085 * You must specify either N or alpha. You cannot specify both.
2086 */
2087 N?: never;
2088
2089 /**
2090 * A double that specifies the exponential decay value to use in the exponential moving average calculation. A
2091 * higher alpha value assigns a lower mathematical significance to previous results from the calculation.
2092 *
2093 * You must specify either N or alpha. You cannot specify both.
2094 */
2095 alpha: NumberExpression;
2096 }
2097 }
2098
2099 export interface Integral {
2100 /**
2101 * Returns the approximation of the area under a curve, which is calculated using the trapezoidal rule where each
2102 * set of adjacent documents form a trapezoid using the:
2103 *
2104 * @version 5.0
2105 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/integral/#mongodb-expression-exp.-integral
2106 */
2107 $integral: {
2108 /**
2109 * Specifies the expression to evaluate. You must provide an expression that returns a number.
2110 */
2111 input: NumberExpression;
2112
2113 /**
2114 * A string that specifies the time unit.
2115 */
2116 unit?: DateUnit;
2117 }
2118 }
2119
2120 export interface Max {
2121 /**
2122 * Returns the maximum value. $max compares both value and type, using the specified BSON comparison order for
2123 * values of different types.
2124 *
2125 * @version 5.0
2126 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/max/#mongodb-expression-exp.-max
2127 */
2128 $max: Expression | Expression[];
2129 }
2130
2131 export interface Min {
2132 /**
2133 * Returns the minimum value. $min compares both value and type, using the specified BSON comparison order for
2134 * values of different types.
2135 *
2136 * @version 5.0
2137 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/min/#mongodb-expression-exp.-min
2138 */
2139 $min: Expression | Expression[];
2140 }
2141
2142 export interface Push {
2143 /**
2144 * Returns an array of all values that result from applying an expression to documents.
2145 *
2146 * @version 5.0
2147 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/push/#mongodb-expression-exp.-push
2148 */
2149 $push: Expression | Record<string, Expression>;
2150 }
2151
2152 export interface Rank {
2153 /**
2154 * Returns the document position (known as the rank) relative to other documents in the $setWindowFields stage
2155 * partition.
2156 *
2157 * @version 5.0
2158 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/rank/#mongodb-expression-exp.-rank
2159 */
2160 $rank: Record<string | number | symbol, never>;
2161 }
2162
2163 export interface Shift {
2164 /**
2165 * Returns the value from an expression applied to a document in a specified position relative to the current
2166 * document in the $setWindowFields stage partition.
2167 *
2168 * @version 5.0
2169 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/shift/#mongodb-expression-exp.-shift
2170 */
2171 $shift: {
2172 /**
2173 * Specifies an expression to evaluate and return in the output.
2174 */
2175 output: Expression;
2176 /**
2177 * Specifies an integer with a numeric document position relative to the current document in the output.
2178 */
2179 by: number;
2180 /**
2181 * Specifies an optional default expression to evaluate if the document position is outside of the implicit
2182 * $setWindowFields stage window. The implicit window contains all the documents in the partition.
2183 */
2184 default?: Expression;
2185 }
2186 }
2187
2188 export interface StdDevPop {
2189 /**
2190 * Calculates the population standard deviation of the input values. Use if the values encompass the entire
2191 * population of data you want to represent and do not wish to generalize about a larger population. $stdDevPop
2192 * ignores non-numeric values.
2193 *
2194 * @version 5.0
2195 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/stdDevPop/#mongodb-expression-exp.-stdDevPop
2196 */
2197 $stdDevPop: Expression;
2198 }
2199
2200 export interface StdDevSamp {
2201 /**
2202 * Calculates the sample standard deviation of the input values. Use if the values encompass a sample of a
2203 * population of data from which to generalize about the population. $stdDevSamp ignores non-numeric values.
2204 *
2205 * @version 5.0
2206 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/stdDevSamp/#mongodb-expression-exp.-stdDevSamp
2207 */
2208 $stdDevSamp: Expression;
2209 }
2210
2211 export interface Sum {
2212 /**
2213 * Calculates and returns the collective sum of numeric values. $sum ignores non-numeric values.
2214 *
2215 * @version 5.0
2216 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/sum/#mongodb-expression-exp.-sum
2217 */
2218 $sum: number | Expression | Expression[];
2219 }
2220
2221 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> {
2222 /**
2223 * Checks if the specified expression resolves to one of the following numeric
2224 * - Integer
2225 * - Decimal
2226 * - Double
2227 * - Long
2228 *
2229 * @version 4.4
2230 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/convert/#mongodb-expression-exp.-convert
2231 */
2232 $convert: {
2233 input: Expression;
2234 to: K;
2235 onError?: Expression;
2236 onNull?: Expression;
2237 };
2238 }
2239
2240 export interface IsNumber {
2241 /**
2242 * Checks if the specified expression resolves to one of the following numeric
2243 * - Integer
2244 * - Decimal
2245 * - Double
2246 * - Long
2247 *
2248 * @version 4.4
2249 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/isNumber/#mongodb-expression-exp.-isNumber
2250 */
2251 $isNumber: Expression;
2252 }
2253
2254 export interface ToBool {
2255 /**
2256 * Converts a value to a boolean.
2257 *
2258 * @version 4.0
2259 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/toBool/#mongodb-expression-exp.-toBool
2260 */
2261 $toBool: Expression;
2262 }
2263
2264 export interface ToDecimal {
2265 /**
2266 * Converts a value to a decimal. If the value cannot be converted to a decimal, $toDecimal errors. If the value
2267 * is null or missing, $toDecimal returns null.
2268 *
2269 * @version 4.0
2270 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/toDecimal/#mongodb-expression-exp.-toDecimal
2271 */
2272 $toDecimal: Expression;
2273 }
2274
2275 export interface ToDouble {
2276 /**
2277 * Converts a value to a double. If the value cannot be converted to an double, $toDouble errors. If the value is
2278 * null or missing, $toDouble returns null.
2279 *
2280 * @version 4.0
2281 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/toDouble/#mongodb-expression-exp.-toDouble
2282 */
2283 $toDouble: Expression;
2284 }
2285
2286 export interface ToInt {
2287 /**
2288 * Converts a value to a long. If the value cannot be converted to a long, $toLong errors. If the value is null or
2289 * missing, $toLong returns null.
2290 *
2291 * @version 4.0
2292 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/toInt/#mongodb-expression-exp.-toInt
2293 */
2294 $toInt: Expression;
2295 }
2296
2297 export interface ToLong {
2298 /**
2299 * Converts a value to a long. If the value cannot be converted to a long, $toLong errors. If the value is null or
2300 * missing, $toLong returns null.
2301 *
2302 * @version 4.0
2303 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/toLong/#mongodb-expression-exp.-toLong
2304 */
2305 $toLong: Expression;
2306 }
2307
2308 export interface ToObjectId {
2309 /**
2310 * Converts a value to an ObjectId(). If the value cannot be converted to an ObjectId, $toObjectId errors. If the
2311 * value is null or missing, $toObjectId returns null.
2312 *
2313 * @version 4.0
2314 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/toObjectId/#mongodb-expression-exp.-toObjectId
2315 */
2316 $toObjectId: Expression;
2317 }
2318
2319 export interface Top {
2320 $top: {
2321 sortBy: AnyObject,
2322 output: Expression
2323 };
2324 }
2325
2326 export interface TopN {
2327 $topN: {
2328 n: Expression,
2329 sortBy: AnyObject,
2330 output: Expression
2331 };
2332 }
2333
2334 export interface ToString {
2335 /**
2336 * Converts a value to a string. If the value cannot be converted to a string, $toString errors. If the value is
2337 * null or missing, $toString returns null.
2338 *
2339 * @version 4.0
2340 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/toString/#mongodb-expression-exp.-toString
2341 */
2342 $toString: Expression;
2343 }
2344
2345 export interface Type {
2346 /**
2347 * Returns a string that specifies the BSON type of the argument.
2348 *
2349 * @version 3.4
2350 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/type/#mongodb-expression-exp.-type
2351 */
2352 $type: Expression;
2353 }
2354
2355 export interface BinarySize {
2356 /**
2357 * Returns the size of a given string or binary data value's content in bytes.
2358 *
2359 * @version 4.4
2360 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/binarySize/#mongodb-expression-exp.-binarySize
2361 */
2362 $binarySize: NullExpression | StringExpression | BinaryExpression;
2363 }
2364
2365 export interface BsonSize {
2366 /**
2367 * Returns the size in bytes of a given document (i.e. bsontype Object) when encoded as BSON. You can use
2368 * $bsonSize as an alternative to the Object.bsonSize() method.
2369 *
2370 * @version 4.4
2371 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/bsonSize/#mongodb-expression-exp.-bsonSize
2372 */
2373 $bsonSize: NullExpression | ObjectExpression;
2374 }
2375
2376 export interface Function {
2377 /**
2378 * Defines a custom aggregation function or expression in JavaScript.
2379 *
2380 * @version 4.4
2381 * @see https://docs.mongodb.com/manual/reference/operator/aggregation/function/#mongodb-expression-exp.-function
2382 */
2383 $function: {
2384 /**
2385 * The function definition. You can specify the function definition as either BSON type Code or String.
2386 */
2387 body: CodeExpression;
2388 /**
2389 * Arguments passed to the function body. If the body function does not take an argument, you can specify an
2390 * empty array [ ]
2391 */
2392 args: ArrayExpression;
2393 /**
2394 * The language used in the body. You must specify lang: "js".
2395 */
2396 lang: 'js'
2397 };
2398 }
2399 }
2400
2401 type Path = string;
2402
2403
2404 export type Expression =
2405 Path |
2406 ArithmeticExpressionOperator |
2407 ArrayExpressionOperator |
2408 BooleanExpressionOperator |
2409 ComparisonExpressionOperator |
2410 ConditionalExpressionOperator |
2411 CustomAggregationExpressionOperator |
2412 DataSizeOperator |
2413 DateExpressionOperator |
2414 LiteralExpressionOperator |
2415 MiscellaneousExpressionOperator |
2416 ObjectExpressionOperator |
2417 SetExpressionOperator |
2418 StringExpressionOperator |
2419 TextExpressionOperator |
2420 TrigonometryExpressionOperator |
2421 TypeExpressionOperator |
2422 AccumulatorOperator |
2423 VariableExpressionOperator |
2424 WindowOperator |
2425 Expression.Top |
2426 Expression.TopN |
2427 any;
2428
2429 export type NullExpression = null;
2430
2431 export type CodeExpression =
2432 string |
2433 Function;
2434
2435 export type BinaryExpression =
2436 Path;
2437
2438 export type FunctionExpression =
2439 Expression.Function;
2440
2441 export type AnyExpression =
2442 ArrayExpression |
2443 BooleanExpression |
2444 NumberExpression |
2445 ObjectExpression |
2446 StringExpression |
2447 DateExpression |
2448 BinaryExpression |
2449 FunctionExpression |
2450 ObjectIdExpression |
2451 ConditionalExpressionOperator |
2452 any;
2453
2454 export type ObjectIdExpression =
2455 TypeExpressionOperatorReturningObjectId;
2456
2457 export type ArrayExpression<T = any> =
2458 T[] |
2459 Path |
2460 ArrayExpressionOperatorReturningAny |
2461 ArrayExpressionOperatorReturningArray |
2462 StringExpressionOperatorReturningArray |
2463 ObjectExpressionOperatorReturningArray |
2464 SetExpressionOperatorReturningArray |
2465 LiteralExpressionOperatorReturningAny |
2466 WindowOperatorReturningArray |
2467 CustomAggregationExpressionOperatorReturningAny |
2468 WindowOperatorReturningAny;
2469
2470 export type BooleanExpression =
2471 boolean |
2472 Path |
2473 BooleanExpressionOperator |
2474 ArrayExpressionOperatorReturningAny |
2475 ComparisonExpressionOperatorReturningBoolean |
2476 StringExpressionOperatorReturningBoolean |
2477 SetExpressionOperatorReturningBoolean |
2478 LiteralExpressionOperatorReturningAny |
2479 CustomAggregationExpressionOperatorReturningAny |
2480 TypeExpressionOperatorReturningBoolean;
2481
2482 export type NumberExpression =
2483 number |
2484 Path |
2485 ArrayExpressionOperatorReturningAny |
2486 ArrayExpressionOperatorReturningNumber |
2487 ArithmeticExpressionOperator |
2488 ComparisonExpressionOperatorReturningNumber |
2489 TrigonometryExpressionOperator |
2490 MiscellaneousExpressionOperatorReturningNumber |
2491 StringExpressionOperatorReturningNumber |
2492 LiteralExpressionOperatorReturningAny |
2493 ObjectExpressionOperator |
2494 SetExpressionOperator |
2495 WindowOperatorReturningNumber |
2496 WindowOperatorReturningAny |
2497 DataSizeOperatorReturningNumber |
2498 CustomAggregationExpressionOperatorReturningAny |
2499 TypeExpressionOperatorReturningNumber |
2500 DateExpression |
2501 DateExpressionOperatorReturningNumber;
2502
2503 export type ObjectExpression =
2504 Path |
2505 ArrayExpressionOperatorReturningAny |
2506 DateExpressionOperatorReturningObject |
2507 StringExpressionOperatorReturningObject |
2508 ObjectExpressionOperatorReturningObject |
2509 CustomAggregationExpressionOperatorReturningAny |
2510 LiteralExpressionOperatorReturningAny;
2511
2512 export type StringExpression<T = string> =
2513 Path |
2514 ArrayExpressionOperatorReturningAny |
2515 DateExpressionOperatorReturningString |
2516 StringExpressionOperatorReturningString |
2517 LiteralExpressionReturningAny |
2518 CustomAggregationExpressionOperatorReturningAny |
2519 TypeExpressionOperatorReturningString |
2520 T;
2521
2522 export type DateExpression =
2523 Path |
2524 NativeDate |
2525 DateExpressionOperatorReturningDate |
2526 TypeExpressionOperatorReturningDate |
2527 LiteralExpressionReturningAny;
2528
2529 export type ArithmeticExpressionOperator =
2530 Expression.Abs |
2531 Expression.Add |
2532 Expression.Ceil |
2533 Expression.Divide |
2534 Expression.Exp |
2535 Expression.Floor |
2536 Expression.Ln |
2537 Expression.Log |
2538 Expression.Log10 |
2539 Expression.Mod |
2540 Expression.Multiply |
2541 Expression.Pow |
2542 Expression.Round |
2543 Expression.Sqrt |
2544 Expression.Subtract |
2545 Expression.Trunc;
2546
2547 export type ArrayExpressionOperator =
2548 ArrayExpressionOperatorReturningAny |
2549 ArrayExpressionOperatorReturningBoolean |
2550 ArrayExpressionOperatorReturningNumber |
2551 ArrayExpressionOperatorReturningObject;
2552
2553 export type LiteralExpressionOperator =
2554 Expression.Literal;
2555
2556 export type LiteralExpressionReturningAny =
2557 LiteralExpressionOperatorReturningAny;
2558
2559 export type LiteralExpressionOperatorReturningAny =
2560 Expression.Literal;
2561
2562 export type MiscellaneousExpressionOperator =
2563 Expression.Rand |
2564 Expression.SampleRate;
2565
2566 export type MiscellaneousExpressionOperatorReturningNumber =
2567 Expression.Rand;
2568
2569 export type ArrayExpressionOperatorReturningAny =
2570 Expression.ArrayElemAt |
2571 Expression.First |
2572 Expression.Last |
2573 Expression.Reduce;
2574
2575 export type ArrayExpressionOperatorReturningArray =
2576 Expression.ConcatArrays |
2577 Expression.Filter |
2578 Expression.Map |
2579 Expression.ObjectToArray |
2580 Expression.Range |
2581 Expression.ReverseArray |
2582 Expression.Slice |
2583 Expression.Zip;
2584
2585 export type ArrayExpressionOperatorReturningNumber =
2586 Expression.IndexOfArray |
2587 Expression.Size;
2588
2589 export type ArrayExpressionOperatorReturningObject =
2590 Expression.ArrayToObject;
2591
2592 export type ArrayExpressionOperatorReturningBoolean =
2593 Expression.In |
2594 Expression.IsArray;
2595
2596 export type BooleanExpressionOperator =
2597 Expression.And |
2598 Expression.Or |
2599 Expression.Not;
2600
2601 export type ComparisonExpressionOperator =
2602 ComparisonExpressionOperatorReturningBoolean |
2603 ComparisonExpressionOperatorReturningNumber;
2604
2605 export type ComparisonExpressionOperatorReturningBoolean =
2606 Expression.Eq |
2607 Expression.Gt |
2608 Expression.Gte |
2609 Expression.Lt |
2610 Expression.Lte |
2611 Expression.Ne;
2612
2613 export type ComparisonExpressionOperatorReturningNumber =
2614 Expression.Cmp;
2615
2616 export type ConditionalExpressionOperator =
2617 Expression.Cond |
2618 Expression.IfNull |
2619 Expression.Switch;
2620
2621 export type StringExpressionOperator =
2622 StringExpressionOperatorReturningArray |
2623 StringExpressionOperatorReturningBoolean |
2624 StringExpressionOperatorReturningNumber |
2625 StringExpressionOperatorReturningObject |
2626 StringExpressionOperatorReturningString;
2627
2628 export type StringExpressionOperatorReturningArray =
2629 Expression.RegexFindAll |
2630 Expression.Split;
2631
2632 export type StringExpressionOperatorReturningBoolean =
2633 Expression.RegexMatch;
2634
2635 export type StringExpressionOperatorReturningNumber =
2636 Expression.IndexOfBytes |
2637 Expression.IndexOfCP |
2638 Expression.Strcasecmp |
2639 Expression.StrLenBytes |
2640 Expression.StrLenCP;
2641
2642 export type StringExpressionOperatorReturningObject =
2643 Expression.RegexFind;
2644
2645 export type StringExpressionOperatorReturningString =
2646 Expression.Concat |
2647 Expression.Ltrim |
2648 Expression.Ltrim |
2649 Expression.ReplaceOne |
2650 Expression.ReplaceAll |
2651 Expression.Substr |
2652 Expression.SubstrBytes |
2653 Expression.SubstrCP |
2654 Expression.ToLower |
2655 Expression.ToString |
2656 Expression.ToUpper |
2657 Expression.Trim;
2658
2659 export type ObjectExpressionOperator =
2660 Expression.MergeObjects |
2661 Expression.ObjectToArray |
2662 Expression.SetField |
2663 Expression.UnsetField;
2664
2665 export type ObjectExpressionOperatorReturningArray =
2666 Expression.ObjectToArray;
2667
2668 export type ObjectExpressionOperatorReturningObject =
2669 Expression.MergeObjects |
2670 Expression.SetField |
2671 Expression.UnsetField;
2672
2673 export type VariableExpressionOperator =
2674 Expression.Let;
2675
2676 export type VariableExpressionOperatorReturningAny =
2677 Expression.Let;
2678
2679 export type SetExpressionOperator =
2680 Expression.AllElementsTrue |
2681 Expression.AnyElementsTrue |
2682 Expression.SetDifference |
2683 Expression.SetEquals |
2684 Expression.SetIntersection |
2685 Expression.SetIsSubset |
2686 Expression.SetUnion;
2687
2688 export type SetExpressionOperatorReturningBoolean =
2689 Expression.AllElementsTrue |
2690 Expression.AnyElementsTrue |
2691 Expression.SetEquals |
2692 Expression.SetIsSubset;
2693
2694 export type SetExpressionOperatorReturningArray =
2695 Expression.SetDifference |
2696 Expression.SetIntersection |
2697 Expression.SetUnion;
2698
2699 /**
2700 * Trigonometry expressions perform trigonometric operations on numbers.
2701 * Values that represent angles are always input or output in radians.
2702 * Use $degreesToRadians and $radiansToDegrees to convert between degree
2703 * and radian measurements.
2704 */
2705 export type TrigonometryExpressionOperator =
2706 Expression.Sin |
2707 Expression.Cos |
2708 Expression.Tan |
2709 Expression.Asin |
2710 Expression.Acos |
2711 Expression.Atan |
2712 Expression.Atan2 |
2713 Expression.Asinh |
2714 Expression.Acosh |
2715 Expression.Atanh |
2716 Expression.Sinh |
2717 Expression.Cosh |
2718 Expression.Tanh |
2719 Expression.DegreesToRadians |
2720 Expression.RadiansToDegrees;
2721
2722 export type TextExpressionOperator =
2723 Expression.Meta;
2724
2725 export type WindowOperator =
2726 Expression.AddToSet |
2727 Expression.Avg |
2728 Expression.Count |
2729 Expression.CovariancePop |
2730 Expression.CovarianceSamp |
2731 Expression.DenseRank |
2732 Expression.Derivative |
2733 Expression.DocumentNumber |
2734 Expression.ExpMovingAvg |
2735 Expression.First |
2736 Expression.Integral |
2737 Expression.Last |
2738 Expression.Max |
2739 Expression.Min |
2740 Expression.Push |
2741 Expression.Rank |
2742 Expression.Shift |
2743 Expression.StdDevPop |
2744 Expression.StdDevSamp |
2745 Expression.Sum;
2746
2747 export type WindowOperatorReturningAny =
2748 Expression.First |
2749 Expression.Last |
2750 Expression.Shift;
2751
2752 export type WindowOperatorReturningArray =
2753 Expression.AddToSet |
2754 Expression.Push;
2755
2756 export type WindowOperatorReturningNumber =
2757 Expression.Avg |
2758 Expression.Count |
2759 Expression.CovariancePop |
2760 Expression.CovarianceSamp |
2761 Expression.DenseRank |
2762 Expression.DocumentNumber |
2763 Expression.ExpMovingAvg |
2764 Expression.Integral |
2765 Expression.Max |
2766 Expression.Min |
2767 Expression.StdDevPop |
2768 Expression.StdDevSamp |
2769 Expression.Sum;
2770
2771 export type TypeExpressionOperator =
2772 Expression.Convert |
2773 Expression.IsNumber |
2774 Expression.ToBool |
2775 Expression.ToDate |
2776 Expression.ToDecimal |
2777 Expression.ToDouble |
2778 Expression.ToInt |
2779 Expression.ToLong |
2780 Expression.ToObjectId |
2781 Expression.ToString |
2782 Expression.Type;
2783
2784 export type TypeExpressionOperatorReturningNumber =
2785 Expression.Convert<'double' | 1 | 'int' | 16 | 'long' | 18 | 'decimal' | 19> |
2786 Expression.ToDecimal |
2787 Expression.ToDouble |
2788 Expression.ToInt |
2789 Expression.ToLong;
2790
2791 export type TypeExpressionOperatorReturningBoolean =
2792 Expression.Convert<'bool' | 8> |
2793 Expression.IsNumber |
2794 Expression.ToBool;
2795
2796
2797 export type TypeExpressionOperatorReturningString =
2798 Expression.Convert<'string' | 2> |
2799 Expression.ToString |
2800 Expression.Type;
2801
2802 export type TypeExpressionOperatorReturningObjectId =
2803 Expression.Convert<'objectId' | 7> |
2804 Expression.ToObjectId;
2805
2806 export type TypeExpressionOperatorReturningDate =
2807 Expression.Convert<'date' | 9> |
2808 Expression.ToDate;
2809
2810 export type DataSizeOperator =
2811 Expression.BinarySize |
2812 Expression.BsonSize;
2813
2814 export type DataSizeOperatorReturningNumber =
2815 Expression.BinarySize |
2816 Expression.BsonSize;
2817
2818 export type CustomAggregationExpressionOperator =
2819 Expression.Accumulator |
2820 Expression.Function;
2821
2822 export type CustomAggregationExpressionOperatorReturningAny =
2823 Expression.Function;
2824
2825 export type AccumulatorOperator =
2826 Expression.Accumulator |
2827 Expression.AddToSet |
2828 Expression.Avg |
2829 Expression.Count |
2830 Expression.First |
2831 Expression.Last |
2832 Expression.Max |
2833 Expression.MergeObjects |
2834 Expression.Min |
2835 Expression.Push |
2836 Expression.StdDevPop |
2837 Expression.StdDevSamp |
2838 Expression.Sum |
2839 Expression.TopN;
2840
2841 export type tzExpression = UTCOffset | StringExpressionOperatorReturningBoolean | string;
2842
2843 type hh = '-00' | '-01' | '-02' | '-03' | '-04' | '-05' | '-06' | '-07' | '-08' | '-09' | '-10' | '-11' | '-12' |
2844 '+00' | '+01' | '+02' | '+03' | '+04' | '+05' | '+06' | '+07' | '+08' | '+09' | '+10' | '+11' | '+12' | '+13' | '+14';
2845 type mm = '00' | '30' | '45';
2846
2847 type UTCOffset = `${hh}` | `${hh}${mm}` | `${hh}:${mm}`;
2848
2849 type RegexOptions =
2850 'i' | 'm' | 's' | 'x' |
2851 'is' | 'im' | 'ix' | 'si' | 'sm' | 'sx' | 'mi' | 'ms' | 'mx' | 'xi' | 'xs' | 'xm' |
2852 'ism' | 'isx' | 'ims' | 'imx' | 'ixs' | 'ixm' | 'sim' | 'six' | 'smi' | 'smx' | 'sxi' | 'sxm' | 'mis' | 'mix' | 'msi' | 'msx' | 'mxi' | 'mxs' | 'xis' | 'xim' | 'xsi' | 'xsm' | 'xmi' | 'xms' |
2853 'ismx' | 'isxm' | 'imsx' | 'imxs' | 'ixsm' | 'ixms' | 'simx' | 'sixm' | 'smix' | 'smxi' | 'sxim' | 'sxmi' | 'misx' | 'mixs' | 'msix' | 'msxi' | 'mxis' | 'mxsi' | 'xism' | 'xims' | 'xsim' | 'xsmi' | 'xmis' | 'xmsi';
2854
2855 type StartOfWeek =
2856 'monday' | 'mon' |
2857 'tuesday' | 'tue' |
2858 'wednesday' | 'wed' |
2859 'thursday' | 'thu' |
2860 'friday' | 'fri' |
2861 'saturday' | 'sat' |
2862 'sunday' | 'sun';
2863
2864 type DateUnit = 'year' | 'quarter' | 'week' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond';
2865
2866 type FormatString = string;
2867
2868 export type DateExpressionOperator =
2869 DateExpressionOperatorReturningDate |
2870 DateExpressionOperatorReturningNumber |
2871 DateExpressionOperatorReturningString |
2872 DateExpressionOperatorReturningObject;
2873
2874 export type DateExpressionOperatorReturningObject =
2875 Expression.DateToParts;
2876
2877 export type DateExpressionOperatorReturningNumber =
2878 Expression.DateDiff |
2879 Expression.DayOfMonth |
2880 Expression.DayOfWeek |
2881 Expression.DayOfYear |
2882 Expression.IsoDayOfWeek |
2883 Expression.IsoWeek |
2884 Expression.IsoWeekYear |
2885 Expression.Millisecond |
2886 Expression.Second |
2887 Expression.Minute |
2888 Expression.Hour |
2889 Expression.Month |
2890 Expression.Year;
2891
2892 export type DateExpressionOperatorReturningDate =
2893 Expression.DateAdd |
2894 Expression.DateFromParts |
2895 Expression.DateFromString |
2896 Expression.DateSubtract |
2897 Expression.DateTrunc |
2898 Expression.ToDate;
2899
2900 export type DateExpressionOperatorReturningString =
2901 Expression.DateToString;
2902
2903}