UNPKG

mongodb-aggregation-dts

Version:

Type definitions for MongoDB aggregation pipelines and operators

1,116 lines 116 kB
export declare class NativeDate extends global.Date { } type SpecialPathVariables = "$$ROOT" | "$$CURRENT" | "$$REMOVE"; export interface AnyObject { [k: string]: any; } export declare namespace Expression { interface Abs { /** * Returns the absolute value of a number. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/abs/#mongodb-expression-exp.-abs */ $abs: Path | ArithmeticExpressionOperator; } interface Add { /** * 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. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/add/#mongodb-expression-exp.-add */ $add: Expression[]; } interface Ceil { /** * Returns the smallest integer greater than or equal to the specified number. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/ceil/#mongodb-expression-exp.-ceil */ $ceil: NumberExpression; } interface Divide { /** * Returns the result of dividing the first number by the second. Accepts two argument expressions. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/divide/#mongodb-expression-exp.-divide */ $divide: NumberExpression[]; } interface Exp { /** * Raises e to the specified exponent. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/exp/#mongodb-expression-exp.-exp */ $exp: NumberExpression; } interface Floor { /** * Returns the largest integer less than or equal to the specified number. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/floor/#mongodb-expression-exp.-floor */ $floor: NumberExpression; } interface Ln { /** * Calculates the natural log of a number. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/ln/#mongodb-expression-exp.-ln */ $ln: NumberExpression; } interface Log { /** * Calculates the log of a number in the specified base. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/log/#mongodb-expression-exp.-log */ $log: [NumberExpression, NumberExpression]; } interface Log10 { /** * Calculates the log base 10 of a number. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/log10/#mongodb-expression-exp.-log10 */ $log10: NumberExpression; } interface Mod { /** * Returns the remainder of the first number divided by the second. Accepts two argument expressions. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/mod/#mongodb-expression-exp.-mod */ $mod: [NumberExpression, NumberExpression]; } interface Multiply { /** * Multiplies numbers to return the product. Accepts any number of argument expressions. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/multiply/#mongodb-expression-exp.-multiply */ $multiply: NumberExpression[]; } interface Pow { /** * Raises a number to the specified exponent. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/pow/#mongodb-expression-exp.-pow */ $pow: [NumberExpression, NumberExpression]; } interface Round { /** * Rounds a number to to a whole integer or to a specified decimal place. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/round/#mongodb-expression-exp.-round */ $round: [NumberExpression, NumberExpression?]; } interface Sqrt { /** * Calculates the square root. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/sqrt/#mongodb-expression-exp.-sqrt */ $sqrt: NumberExpression; } interface Subtract { /** * 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. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/subtract/#mongodb-expression-exp.-subtract */ $subtract: (NumberExpression | DateExpression)[]; } interface Trunc { /** * Truncates a number to a whole integer or to a specified decimal place. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/trunc/#mongodb-expression-exp.-trunc */ $trunc: [NumberExpression, NumberExpression?]; } interface Sin { /** * Returns the sine of a value that is measured in radians. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/sin/#mongodb-expression-exp.-sin */ $sin: NumberExpression; } interface Cos { /** * Returns the cosine of a value that is measured in radians. * * @version 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/cos/#mongodb-expression-exp.-cos */ $cos: NumberExpression; } interface Tan { /** * Returns the tangent of a value that is measured in radians. * * @version 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/tan/#mongodb-expression-exp.-tan */ $tan: NumberExpression; } interface Asin { /** * Returns the inverse sin (arc sine) of a value in radians. * * @version 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/asin/#mongodb-expression-exp.-asin */ $asin: NumberExpression; } interface Acos { /** * Returns the inverse cosine (arc cosine) of a value in radians. * * @version 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/acos/#mongodb-expression-exp.-acos */ $acos: NumberExpression; } interface Atan { /** * Returns the inverse tangent (arc tangent) of a value in radians. * * @version 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/atan/#mongodb-expression-exp.-atan */ $atan: NumberExpression; } interface Atan2 { /** * 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. * * @version 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/atan2/#mongodb-expression-exp.-atan2 */ $atan2: NumberExpression; } interface Asinh { /** * Returns the inverse hyperbolic sine (hyperbolic arc sine) of a value in radians. * * @version 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/asinh/#mongodb-expression-exp.-asinh */ $asinh: NumberExpression; } interface Acosh { /** * Returns the inverse hyperbolic cosine (hyperbolic arc cosine) of a value in radians. * * @version 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/acosh/#mongodb-expression-exp.-acosh */ $acosh: NumberExpression; } interface Atanh { /** * Returns the inverse hyperbolic tangent (hyperbolic arc tangent) of a value in radians. * * @version 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/atanh/#mongodb-expression-exp.-atanh */ $atanh: NumberExpression; } interface Sinh { /** * Returns the hyperbolic sine of a value that is measured in radians. * * @version 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/sinh/#mongodb-expression-exp.-sinh */ $sinh: NumberExpression; } interface Cosh { /** * Returns the hyperbolic cosine of a value that is measured in radians. * * @version 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/cosh/#mongodb-expression-exp.-cosh */ $cosh: NumberExpression; } interface Tanh { /** * Returns the hyperbolic tangent of a value that is measured in radians. * * @version 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/tanh/#mongodb-expression-exp.-tanh */ $tanh: NumberExpression; } interface DegreesToRadians { /** * Converts a value from degrees to radians. * * @version 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/degreesToRadians/#mongodb-expression-exp.-degreesToRadians */ $degreesToRadians: NumberExpression; } interface RadiansToDegrees { /** * Converts a value from radians to degrees. * * @version 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/radiansToDegrees/#mongodb-expression-exp.-radiansToDegrees */ $radiansToDegrees: NumberExpression; } interface Meta { /** * Access available per-document metadata related to the aggregation operation. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/meta/#mongodb-expression-exp.-meta */ $meta: "textScore" | "indexKey"; } interface DateAdd { /** * Adds a number of time units to a date object. * * @version 5.0.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateAdd/#mongodb-expression-exp.-dateAdd */ $dateAdd: { /** * 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. */ startDate: DateExpression; /** * 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: * - year * - quarter * - week * - month * - day * - hour * - minute * - second * - millisecond */ unit: StringExpression<DateUnit>; /** * 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. */ amount: NumberExpression; /** * 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. */ timezone?: tzExpression; }; } interface DateDiff { /** * Returns the difference between two dates. * * @version 5.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateDiff/#mongodb-expression-exp.-dateDiff */ $dateDiff: { /** * The start of the time period. The startDate can be any expression that resolves to a Date, a Timestamp, or an ObjectID. */ startDate: DateExpression; /** * The end of the time period. The endDate can be any expression that resolves to a Date, a Timestamp, or an ObjectID. */ endDate: DateExpression; /** * The time measurement unit between the startDate and endDate. It is an expression that resolves to a string: * - year * - quarter * - week * - month * - day * - hour * - minute * - second * - millisecond */ unit: StringExpression<DateUnit>; /** * 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. */ timezone?: tzExpression; /** * Used when the unit is equal to week. Defaults to Sunday. The startOfWeek parameter is an expression that resolves to a case insensitive string: * - monday (or mon) * - tuesday (or tue) * - wednesday (or wed) * - thursday (or thu) * - friday (or fri) * - saturday (or sat) * - sunday (or sun) */ startOfWeek?: StringExpression<StartOfWeek>; }; } interface DateFromParts { /** * Constructs a BSON Date object given the date's constituent parts. * * @version 3.6 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateFromParts/#mongodb-expression-exp.-dateFromParts */ $dateFromParts: { /** * ISO Week Date Year. Can be any expression that evaluates to a number. * * Value range: 1-9999 * * 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. */ isoWeekYear?: NumberExpression; /** * Week of year. Can be any expression that evaluates to a number. * * Defaults to 1. * * Value range: 1-53 * * 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. */ isoWeek?: NumberExpression; /** * Day of week (Monday 1 - Sunday 7). Can be any expression that evaluates to a number. * * Defaults to 1. * * Value range: 1-7 * * 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. */ isoDayOfWeek?: NumberExpression; /** * Calendar year. Can be any expression that evaluates to a number. * * Value range: 1-9999 * * 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. */ year?: NumberExpression; /** * Month. Can be any expression that evaluates to a number. * * Defaults to 1. * * Value range: 1-12 * * 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. */ month?: NumberExpression; /** * Day of month. Can be any expression that evaluates to a number. * * Defaults to 1. * * Value range: 1-31 * * 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. */ day?: NumberExpression; /** * Hour. Can be any expression that evaluates to a number. * * Defaults to 0. * * Value range: 0-23 * * 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. */ hour?: NumberExpression; /** * Minute. Can be any expression that evaluates to a number. * * Defaults to 0. * * 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. */ minute?: NumberExpression; /** * Second. Can be any expression that evaluates to a number. * * Defaults to 0. * * 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. */ second?: NumberExpression; /** * Millisecond. Can be any expression that evaluates to a number. * * Defaults to 0. * * Value range: 0-999 * * 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. */ millisecond?: NumberExpression; /** * 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. */ timezone?: tzExpression; }; } interface DateFromString { /** * Converts a date/time string to a date object. * * @version 3.6 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateFromString/#mongodb-expression-exp.-dateFromString */ $dateFromString: { dateString: StringExpression<string>; /** * 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. * * If unspecified, $dateFromString uses "%Y-%m-%dT%H:%M:%S.%LZ" as the default format. * @version 4.0 */ format?: FormatString; /** * The time zone to use to format the date. * * 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. */ timezone?: tzExpression; /** * 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. * * If you do not specify onError, $dateFromString throws an error if it cannot parse dateString. */ onError?: Expression; /** * 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. * * If you do not specify onNull and dateString is null or missing, then $dateFromString outputs null. */ onNull?: Expression; }; } interface DateSubtract { /** * Subtracts a number of time units from a date object. * * @version 5.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateSubtract/#mongodb-expression-exp.-dateSubtract */ $dateSubtract: { /** * 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. */ startDate: DateExpression; /** * The unit of time, specified as an expression that must resolve to one of these strings: * - year * - quarter * - week * - month * - day * - hour * - minute * - second * - millisecond * * Together, binSize and unit specify the time period used in the $dateTrunc calculation. */ unit: StringExpression<DateUnit>; /** * 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. */ amount: NumberExpression; /** * 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. */ timezone?: tzExpression; }; } interface DateToParts { /** * Returns a document containing the constituent parts of a date. * * @version 3.6 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateToParts/#mongodb-expression-exp.-dateToParts */ $dateToParts: { /** * 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. */ date: DateExpression; /** * 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. * * @version 3.6 */ timezone?: tzExpression; /** * If set to true, modifies the output document to use ISO week date fields. Defaults to false. */ iso8601?: boolean; }; } interface DateToString { /** * Returns the date as a formatted string. * * @version 3.6 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateToString/#mongodb-expression-exp.-dateToString */ $dateToString: { /** * The date to convert to string. <dateExpression> must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. */ date: DateExpression; /** * 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. * * If unspecified, $dateToString uses "%Y-%m-%dT%H:%M:%S.%LZ" as the default format. * * 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. */ format?: FormatString; /** * 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. * * @version 3.6 */ timezone?: tzExpression; /** * The value to return if the date is null or missing. The arguments can be any valid expression. * * If unspecified, $dateToString returns null if the date is null or missing. * * Changed in version 4.0: Requires featureCompatibilityVersion (fCV) set to "4.0" or greater. For more information on fCV, see setFeatureCompatibilityVersion. */ onNull?: Expression; }; } interface DateTrunc { /** * Truncates a date. * * @version 5.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateTrunc/#mongodb-expression-exp.-dateTrunc */ $dateTrunc: { /** * The date to truncate, specified in UTC. The date can be any expression that resolves to a Date, a Timestamp, or an ObjectID. */ date: DateExpression; /** * The unit of time, specified as an expression that must resolve to one of these strings: * - year * - quarter * - week * - month * - day * - hour * - minute * - second * - millisecond * * Together, binSize and unit specify the time period used in the $dateTrunc calculation. */ unit: StringExpression<DateUnit>; /** * The numeric time value, specified as an expression that must resolve to a positive non-zero number. Defaults to 1. * * Together, binSize and unit specify the time period used in the $dateTrunc calculation. */ binSize?: NumberExpression; /** * 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. */ timezone?: tzExpression; /** * Used when the unit is equal to week. Defaults to Sunday. The startOfWeek parameter is an expression that resolves to a case insensitive string: * - monday (or mon) * - tuesday (or tue) * - wednesday (or wed) * - thursday (or thu) * - friday (or fri) * - saturday (or sat) * - sunday (or sun) */ startOfWeek?: StringExpression<StartOfWeek>; }; } interface DayOfMonth { /** * Returns the day of the month for a date as a number between 1 and 31. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfMonth/#mongodb-expression-exp.-dayOfMonth */ $dayOfMonth: DateExpression | { /** * The date to which the operator is applied. <dateExpression> must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. */ date: DateExpression; /** * 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. */ timezone?: tzExpression; }; } interface DayOfWeek { /** * Returns the day of the week for a date as a number between 1 (Sunday) and 7 (Saturday). * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfWeek/#mongodb-expression-exp.-dayOfWeek */ $dayOfWeek: DateExpression | { /** * The date to which the operator is applied. <dateExpression> must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. */ date: DateExpression; /** * 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. */ timezone?: tzExpression; }; } interface DayOfYear { /** * Returns the day of the year for a date as a number between 1 and 366 (leap year). * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfYear/#mongodb-expression-exp.-dayOfYear */ $dayOfYear: DateExpression | { /** * The date to which the operator is applied. <dateExpression> must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. */ date: DateExpression; /** * 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. */ timezone?: tzExpression; }; } interface Hour { /** * Returns the hour for a date as a number between 0 and 23. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/hour/#mongodb-expression-exp.-hour */ $hour: DateExpression | { /** * The date to which the operator is applied. <dateExpression> must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. */ date: DateExpression; /** * 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. */ timezone?: tzExpression; }; } interface IsoDayOfWeek { /** * Returns the weekday number in ISO 8601 format, ranging from 1 (for Monday) to 7 (for Sunday). * * @version 3.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoDayOfWeek/#mongodb-expression-exp.-isoDayOfWeek */ $isoDayOfWeek: DateExpression | { /** * The date to which the operator is applied. <dateExpression> must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. */ date: DateExpression; /** * 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. */ timezone?: tzExpression; }; } interface IsoWeek { /** * 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. * * @version 3.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeek/#mongodb-expression-exp.-isoWeek */ $isoWeek: DateExpression | { /** * The date to which the operator is applied. <dateExpression> must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. */ date: DateExpression; /** * 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. */ timezone?: tzExpression; }; } interface IsoWeekYear { /** * 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). * * @version 3.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeekYear/#mongodb-expression-exp.-isoWeekYear */ $isoWeekYear: DateExpression | { /** * The date to which the operator is applied. <dateExpression> must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. */ date: DateExpression; /** * 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. */ timezone?: tzExpression; }; } interface Millisecond { /** * Returns the milliseconds of a date as a number between 0 and 999. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/millisecond/#mongodb-expression-exp.-millisecond */ $millisecond: DateExpression | { /** * The date to which the operator is applied. <dateExpression> must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. */ date: DateExpression; /** * 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. */ timezone?: tzExpression; }; } interface Minute { /** * Returns the minute for a date as a number between 0 and 59. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/minute/#mongodb-expression-exp.-minute */ $minute: DateExpression | { /** * The date to which the operator is applied. <dateExpression> must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. */ date: DateExpression; /** * 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. */ timezone?: tzExpression; }; } interface Month { /** * Returns the month for a date as a number between 1 (January) and 12 (December). * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/month/#mongodb-expression-exp.-month */ $month: DateExpression | { /** * The date to which the operator is applied. <dateExpression> must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. */ date: DateExpression; /** * 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. */ timezone?: tzExpression; }; } interface Second { /** * Returns the seconds for a date as a number between 0 and 60 (leap seconds). * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/second/#mongodb-expression-exp.-second */ $second: DateExpression | { /** * The date to which the operator is applied. <dateExpression> must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. */ date: DateExpression; /** * 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. */ timezone?: tzExpression; }; } interface ToDate { /** * Converts value to a Date. * * @version 4.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toDate/#mongodb-expression-exp.-toDate */ $toDate: Expression; } interface Week { /** * 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). * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/week/#mongodb-expression-exp.-week */ $week: DateExpression | { /** * The date to which the operator is applied. <dateExpression> must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. */ date: DateExpression; /** * 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. */ timezone?: tzExpression; }; } interface Year { /** * Returns the year for a date as a number (e.g. 2014). * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/year/#mongodb-expression-exp.-year */ $year: DateExpression | { /** * The date to which the operator is applied. <dateExpression> must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. */ date: DateExpression; /** * 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. */ timezone?: tzExpression; }; } interface And { /** * Returns true only when all its expressions evaluate to true. Accepts any number of argument expressions. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/and/#mongodb-expression-exp.-and */ $and: (Expression | Record<string, Expression>)[]; } interface Not { /** * Returns the boolean value that is the opposite of its argument expression. Accepts a single argument expression. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/not/#mongodb-expression-exp.-not */ $not: [Expression]; } interface Or { /** * Returns true when any of its expressions evaluates to true. Accepts any number of argument expressions. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/or/#mongodb-expression-exp.-or */ $or: (Expression | Record<string, Expression>)[]; } interface Cmp { /** * 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. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/cmp/#mongodb-expression-exp.-cmp */ $cmp: [ Record<string, AnyExpression> | Expression, Record<string, AnyExpression> | Expression ]; } interface Eq { /** * Returns true if the values are equivalent. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/eq/#mongodb-expression-exp.-eq */ $eq: AnyExpression | [AnyExpression, AnyExpression]; } interface Gt { /** * Returns true if the first value is greater than the second. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/gt/#mongodb-expression-exp.-gt */ $gt: NumberExpression | [NumberExpression, NumberExpression]; } interface Gte { /** * Returns true if the first value is greater than or equal to the second. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/gte/#mongodb-expression-exp.-gte */ $gte: NumberExpression | [NumberExpression, NumberExpression]; } interface Lt { /** * Returns true if the first value is less than the second. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/lt/#mongodb-expression-exp.-lt */ $lt: NumberExpression | [NumberExpression, NumberExpression]; } interface Lte { /** * Returns true if the first value is less than or equal to the second. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/lte/#mongodb-expression-exp.-lte */ $lte: NumberExpression | [NumberExpression, NumberExpression]; } interface Ne { /** * Returns true if the values are not equivalent. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/ne/#mongodb-expression-exp.-ne */ $ne: Expression | [Expression, Expression | NullExpression] | null; } interface Cond { /** * 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. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/cond/#mongodb-expression-exp.-cond */ $cond: { if: Expression; then: AnyExpression; else: AnyExpression; } | [BooleanExpression, AnyExpression, AnyExpression]; } interface IfNull { /** * 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. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/ifNull/#mongodb-expression-exp.-ifNull */ $ifNull: Expression[]; } interface Switch { /** * 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. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/switch/#mongodb-expression-exp.-switch */ $switch: { /** * An array of control branch documents. Each branch is a document with the following fields: * - $case * - $then */ branches: { case: Expression; then: Expression; }[]; /** * The path to take if no branch case expression evaluates to true. * * Although optional, if default is unspecified and no branch case evaluates to true, $switch returns an error. */ default: Expression; }; } interface ArrayElemAt { /** * Returns the element at the specified array index. * * @version 3.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/arrayElemAt/#mongodb-expression-exp.-arrayElemAt */ $arrayElemAt: [ArrayExpression, NumberExpression]; } interface ArrayToObject { /** * Converts an array of key value pairs to a document. * * @version 3.4.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/arrayToObject/#mongodb-expression-exp.-arrayToObject */ $arrayToObject: ArrayExpression; } interface ConcatArrays { /** * Concatenates arrays to return the concatenated array. * * @version 3.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/concatArrays/#mongodb-expression-exp.-concatArrays */ $concatArrays: Expression[]; } interface Filter { /** * Selects a subset of the array to return an array with only the elements that match the filter condition. * * @version 3.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/filter/#mongodb-expression-exp.-filter */ $filter: { /** * An expression that resolves to an array. */ input: ArrayExpression; /** * 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. */ as?: string; /** * 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. */ cond: BooleanExpression; /** * A number expression that restricts the number of matching array elements that $filter returns. You cannot specify a limit less than 1. The matching array elements are returned in the order they appear in the input array. * * If the specified limit is greater than the number of matching array elements, $filter returns all matching array elements. * If the limit is null, $filter returns all matching array elements. * * @version 5.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/filter/#using-the-limit-field */ limit?: NumberExpression; }; } interface First { /** * Returns the first array element. Distinct from $first accumulator. * * @version 5.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/first/#mongodb-expression-exp.-first */ $first: Expression; } interface In { /** * Returns a boolean indicating whether a specified value is in an array. * * @version 3.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/in/#mongodb-expression-exp.-in */ $in: [Expression, ArrayExpression]; } interface IndexOfArray { /** * 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. * * @version 3.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexOfArray/#mongodb-expression-exp.-indexOfArray */ $indexOfArray: [ArrayExpression, Expression] | [ArrayExpression, Expression, NumberExpression] | [ArrayExpression, Expression, NumberExpression, NumberExpression]; } interface IsArray { /** * Determines if the operand is an array. Returns a boolean. * * @version 3.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/isArray/#mongodb-expression-exp.-isArray */ $isArray: [Expression]; } interface Last { /** * Returns the last array element. Distinct from $last accumulator. * * @version 5.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/last/#mongodb-expression-exp.-last */ $last: Expression; } interface LinearFill { /** * Fills null and missing fields in a window using linear interpolation bas