Skip to content

Commit

Permalink
Merge branch 'master' into 8.10
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 authored Feb 5, 2025
2 parents f344f63 + 8a55290 commit 0d41398
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
8.9.7 / 2025-02-04
==================
* fix: avoid applying defaults on map embedded paths #15217 #15196
* types: add missing $median operator to aggregation types #15233 #15209
* docs(document): clarify that toObject() returns a POJO that may contain non-POJO values #15232 #15208

8.9.6 / 2025-01-31
==================
* fix(document): allow setting values to undefined with set(obj) syntax with strict: false #15207 #15192
Expand Down
2 changes: 1 addition & 1 deletion lib/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -4069,7 +4069,7 @@ Document.prototype.$__toObjectShallow = function $__toObjectShallow() {
* @param {Boolean} [options.flattenMaps=false] if true, convert Maps to POJOs. Useful if you want to `JSON.stringify()` the result of `toObject()`.
* @param {Boolean} [options.flattenObjectIds=false] if true, convert any ObjectIds in the result to 24 character hex strings.
* @param {Boolean} [options.useProjection=false] - If true, omits fields that are excluded in this document's projection. Unless you specified a projection, this will omit any field that has `select: false` in the schema.
* @return {Object} js object (not a POJO)
* @return {Object} document as a plain old JavaScript object (POJO). This object may contain ObjectIds, Maps, Dates, mongodb.Binary, Buffers, and other non-POJO values.
* @see mongodb.Binary https://mongodb.github.io/node-mongodb-native/4.9/classes/Binary.html
* @api public
* @memberOf Document
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mongoose",
"description": "Mongoose MongoDB ODM",
"version": "8.9.6",
"version": "8.9.7",
"author": "Guillermo Rauch <[email protected]>",
"keywords": [
"mongodb",
Expand Down
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 0d41398

Please sign in to comment.