Skip to content

Commit

Permalink
Merge pull request #15233 from Automattic/vkarpov15/gh-15209
Browse files Browse the repository at this point in the history
types: add missing $median operator to aggregation types
  • Loading branch information
vkarpov15 authored Feb 4, 2025
2 parents 52f3ced + 2de289b commit bd53c4c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/types/expressions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,3 +313,7 @@ const filterLimit: Expression.Filter = {
}
];
})();

function gh15209() {
const query: PipelineStage[] = [{ $group: { _id: null, median: { $median: { input: '$value', method: 'approximate' } } } }];
}
15 changes: 15 additions & 0 deletions types/expressions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2301,6 +2301,18 @@ declare module 'mongoose' {
}
}

export interface Median {
/**
* Returns an approximation of the median, the 50th percentile, as a scalar value.
*
* @see https://www.mongodb.com/docs/v7.0/reference/operator/aggregation/median/
*/
$median: {
input: number | Expression,
method: 'approximate'
}
}

export interface StdDevPop {
/**
* Calculates the population standard deviation of the input values. Use if the values encompass the entire
Expand Down Expand Up @@ -2859,6 +2871,7 @@ declare module 'mongoose' {
Expression.Locf |
Expression.Max |
Expression.MaxN |
Expression.Median |
Expression.Min |
Expression.MinN |
Expression.Push |
Expand Down Expand Up @@ -2891,6 +2904,7 @@ declare module 'mongoose' {
Expression.ExpMovingAvg |
Expression.Integral |
Expression.Max |
Expression.Median |
Expression.Min |
Expression.StdDevPop |
Expression.StdDevSamp |
Expand Down Expand Up @@ -2963,6 +2977,7 @@ declare module 'mongoose' {
Expression.LastN |
Expression.Max |
Expression.MaxN |
Expression.Median |
Expression.MergeObjects |
Expression.Min |
Expression.MinN |
Expand Down

0 comments on commit bd53c4c

Please sign in to comment.