Skip to content

Commit 0d41398

Browse files
authored
Merge branch 'master' into 8.10
2 parents f344f63 + 8a55290 commit 0d41398

File tree

5 files changed

+27
-2
lines changed

5 files changed

+27
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
8.9.7 / 2025-02-04
2+
==================
3+
* fix: avoid applying defaults on map embedded paths #15217 #15196
4+
* types: add missing $median operator to aggregation types #15233 #15209
5+
* docs(document): clarify that toObject() returns a POJO that may contain non-POJO values #15232 #15208
6+
17
8.9.6 / 2025-01-31
28
==================
39
* fix(document): allow setting values to undefined with set(obj) syntax with strict: false #15207 #15192

lib/document.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4069,7 +4069,7 @@ Document.prototype.$__toObjectShallow = function $__toObjectShallow() {
40694069
* @param {Boolean} [options.flattenMaps=false] if true, convert Maps to POJOs. Useful if you want to `JSON.stringify()` the result of `toObject()`.
40704070
* @param {Boolean} [options.flattenObjectIds=false] if true, convert any ObjectIds in the result to 24 character hex strings.
40714071
* @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.
4072-
* @return {Object} js object (not a POJO)
4072+
* @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.
40734073
* @see mongodb.Binary https://mongodb.github.io/node-mongodb-native/4.9/classes/Binary.html
40744074
* @api public
40754075
* @memberOf Document

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "mongoose",
33
"description": "Mongoose MongoDB ODM",
4-
"version": "8.9.6",
4+
"version": "8.9.7",
55
"author": "Guillermo Rauch <[email protected]>",
66
"keywords": [
77
"mongodb",

test/types/expressions.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,3 +313,7 @@ const filterLimit: Expression.Filter = {
313313
}
314314
];
315315
})();
316+
317+
function gh15209() {
318+
const query: PipelineStage[] = [{ $group: { _id: null, median: { $median: { input: '$value', method: 'approximate' } } } }];
319+
}

types/expressions.d.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2301,6 +2301,18 @@ declare module 'mongoose' {
23012301
}
23022302
}
23032303

2304+
export interface Median {
2305+
/**
2306+
* Returns an approximation of the median, the 50th percentile, as a scalar value.
2307+
*
2308+
* @see https://www.mongodb.com/docs/v7.0/reference/operator/aggregation/median/
2309+
*/
2310+
$median: {
2311+
input: number | Expression,
2312+
method: 'approximate'
2313+
}
2314+
}
2315+
23042316
export interface StdDevPop {
23052317
/**
23062318
* Calculates the population standard deviation of the input values. Use if the values encompass the entire
@@ -2859,6 +2871,7 @@ declare module 'mongoose' {
28592871
Expression.Locf |
28602872
Expression.Max |
28612873
Expression.MaxN |
2874+
Expression.Median |
28622875
Expression.Min |
28632876
Expression.MinN |
28642877
Expression.Push |
@@ -2891,6 +2904,7 @@ declare module 'mongoose' {
28912904
Expression.ExpMovingAvg |
28922905
Expression.Integral |
28932906
Expression.Max |
2907+
Expression.Median |
28942908
Expression.Min |
28952909
Expression.StdDevPop |
28962910
Expression.StdDevSamp |
@@ -2963,6 +2977,7 @@ declare module 'mongoose' {
29632977
Expression.LastN |
29642978
Expression.Max |
29652979
Expression.MaxN |
2980+
Expression.Median |
29662981
Expression.MergeObjects |
29672982
Expression.Min |
29682983
Expression.MinN |

0 commit comments

Comments
 (0)