Skip to content

Commit 0cc0ac3

Browse files
authored
Merge branch '8.0' into vkarpov15/gh-12748
2 parents 9aa8cdf + 73f9412 commit 0cc0ac3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+352
-95
lines changed

.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ module.exports = {
1313
'*.min.js',
1414
'**/docs/js/native.js',
1515
'!.*',
16-
'node_modules'
16+
'node_modules',
17+
'.git'
1718
],
1819
overrides: [
1920
{

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
7.5.3 / 2023-09-25
2+
==================
3+
* fix(document): handle MongoDB Long when casting BigInts #13869 #13791
4+
* fix(model): make bulkSave() persist changes that happen in pre('save') middleware #13885 #13799
5+
* fix: handle casting $elemMatch underneath $not underneath another $elemMatch #13893 #13880
6+
* fix(model): make bulkWrite casting respect global setDefaultsOnInsert #13870 #13823
7+
* fix(document): handle default values for discriminator key with embedded discriminators #13891 #13835
8+
* fix: account for null values when assigning isNew property within document array #13883
9+
* types: avoid "interface can only extend object types with statically known members" error in TypeScript 4 #13871
10+
* docs(deprecations): fix typo in includeResultMetadata deprecation docs #13884 #13844
11+
* docs: fix pre element overflow in home page #13868 [ghoshRitesh12](https://github.com/ghoshRitesh12)
12+
13+
7.5.2 / 2023-09-15
14+
==================
15+
* fix(schema): handle number discriminator keys when using Schema.prototype.discriminator() #13858 #13788
16+
* fix: ignore `id` property when calling `set()` with both `id` and `_id` specified to avoid `id` setter overwriting #13762
17+
* types: pass correct document type to required and default function #13851 #13797
18+
* docs(model): add examples of using diffIndexes() to syncIndexes()and diffIndexes() api docs #13850 #13771
19+
120
7.5.1 / 2023-09-11
221
==================
322
* fix: set default value for _update when no update object is provided and versionKey is set to false #13795 #13783 [MohOraby](https://github.com/MohOraby)

docs/css/style.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ pre {
4646
background: #eee;
4747
padding: 5px;
4848
border-radius: 3px;
49+
overflow-x: auto;
4950
}
5051
code {
5152
color: #333;

docs/deprecations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ cause any problems for your application. Please [report any issues on GitHub](ht
99

1010
To fix all deprecation warnings, follow the below steps:
1111

12-
* Replace `rawResult: true` with `includeResultMetadata: false` in `findOneAndUpdate()`, `findOneAndReplace()`, `findOneAndDelete()` calls.
12+
* Replace `rawResult: true` with `includeResultMetadata: true` in `findOneAndUpdate()`, `findOneAndReplace()`, `findOneAndDelete()` calls.
1313

1414
Read below for more a more detailed description of each deprecation warning.
1515

docs/source/api.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ const files = [
1515
'lib/document.js',
1616
'lib/model.js',
1717
'lib/query.js',
18-
'lib/cursor/QueryCursor.js',
18+
'lib/cursor/queryCursor.js',
1919
'lib/aggregate.js',
20-
'lib/cursor/AggregationCursor.js',
20+
'lib/cursor/aggregationCursor.js',
2121
'lib/schemaType.js',
2222
'lib/virtualType.js',
2323
'lib/error/index.js',
@@ -29,16 +29,16 @@ const files = [
2929
'lib/schema/number.js',
3030
'lib/schema/objectId.js',
3131
'lib/schema/string.js',
32-
'lib/options/SchemaTypeOptions.js',
33-
'lib/options/SchemaArrayOptions.js',
34-
'lib/options/SchemaBufferOptions.js',
35-
'lib/options/SchemaDateOptions.js',
36-
'lib/options/SchemaNumberOptions.js',
37-
'lib/options/SchemaObjectIdOptions.js',
38-
'lib/options/SchemaStringOptions.js',
39-
'lib/types/DocumentArray/methods/index.js',
32+
'lib/options/schemaTypeOptions.js',
33+
'lib/options/schemaArrayOptions.js',
34+
'lib/options/schemaBufferOptions.js',
35+
'lib/options/schemaDateOptions.js',
36+
'lib/options/schemaNumberOptions.js',
37+
'lib/options/schemaObjectIdOptions.js',
38+
'lib/options/schemaStringOptions.js',
39+
'lib/types/documentArray/methods/index.js',
4040
'lib/types/subdocument.js',
41-
'lib/types/ArraySubdocument.js',
41+
'lib/types/arraySubdocument.js',
4242
'lib/types/buffer.js',
4343
'lib/types/decimal128.js',
4444
'lib/types/map.js',

lib/aggregate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Module dependencies
55
*/
66

7-
const AggregationCursor = require('./cursor/AggregationCursor');
7+
const AggregationCursor = require('./cursor/aggregationCursor');
88
const MongooseError = require('./error/mongooseError');
99
const Query = require('./query');
1010
const { applyGlobalMaxTimeMS, applyGlobalDiskUse } = require('./helpers/query/applyGlobalOption');

lib/cast.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,21 @@ module.exports = function cast(schema, obj, options, context) {
309309
while (k--) {
310310
$cond = ks[k];
311311
nested = val[$cond];
312-
313-
if ($cond === '$not') {
312+
if ($cond === '$elemMatch') {
313+
if (nested && schematype != null && schematype.schema != null) {
314+
cast(schematype.schema, nested, options, context);
315+
} else if (nested && schematype != null && schematype.$isMongooseArray) {
316+
if (utils.isPOJO(nested) && nested.$not != null) {
317+
cast(schema, nested, options, context);
318+
} else {
319+
val[$cond] = schematype.castForQuery(
320+
$cond,
321+
nested,
322+
context
323+
);
324+
}
325+
}
326+
} else if ($cond === '$not') {
314327
if (nested && schematype) {
315328
_keys = Object.keys(nested);
316329
if (_keys.length && isOperator(_keys[0])) {
@@ -337,6 +350,7 @@ module.exports = function cast(schema, obj, options, context) {
337350
context
338351
);
339352
}
353+
340354
}
341355
}
342356
} else if (Array.isArray(val) && ['Buffer', 'Array'].indexOf(schematype.instance) === -1) {

lib/cast/bigint.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
const assert = require('assert');
4+
const { Long } = require('bson');
45

56
/**
67
* Given a value, cast it to a BigInt, or throw an `Error` if the value
@@ -23,6 +24,10 @@ module.exports = function castBigInt(val) {
2324
return val;
2425
}
2526

27+
if (val instanceof Long) {
28+
return val.toBigInt();
29+
}
30+
2631
if (typeof val === 'string' || typeof val === 'number') {
2732
return BigInt(val);
2833
}

lib/connection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Module dependencies.
55
*/
66

7-
const ChangeStream = require('./cursor/ChangeStream');
7+
const ChangeStream = require('./cursor/changeStream');
88
const EventEmitter = require('events').EventEmitter;
99
const Schema = require('./schema');
1010
const STATES = require('./connectionState');
File renamed without changes.

0 commit comments

Comments
 (0)