mongoose 8.13.1 → 8.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.umd.js +1 -1
- package/lib/document.js +28 -6
- package/package.json +3 -3
package/lib/document.js
CHANGED
|
@@ -2721,12 +2721,33 @@ function _getPathsToValidate(doc, pathsToValidate, pathsToSkip, isNestedValidate
|
|
|
2721
2721
|
function addToPaths(p) { paths.add(p); }
|
|
2722
2722
|
|
|
2723
2723
|
if (!isNestedValidate) {
|
|
2724
|
-
// If we're validating a subdocument, all this logic will run anyway on the top-level document, so skip for subdocuments
|
|
2725
|
-
|
|
2724
|
+
// If we're validating a subdocument, all this logic will run anyway on the top-level document, so skip for subdocuments.
|
|
2725
|
+
// But only run for top-level subdocuments, because we're looking for subdocuments that are not modified at top-level but
|
|
2726
|
+
// have a modified path. If that is the case, we will run validation on the top-level subdocument, and via that run validation
|
|
2727
|
+
// on any subdocuments down to the modified path.
|
|
2728
|
+
const topLevelSubdocs = [];
|
|
2729
|
+
for (const path of Object.keys(doc.$__schema.paths)) {
|
|
2730
|
+
const schemaType = doc.$__schema.path(path);
|
|
2731
|
+
if (schemaType.$isSingleNested) {
|
|
2732
|
+
const subdoc = doc.$get(path);
|
|
2733
|
+
if (subdoc) {
|
|
2734
|
+
topLevelSubdocs.push(subdoc);
|
|
2735
|
+
}
|
|
2736
|
+
} else if (schemaType.$isMongooseDocumentArray) {
|
|
2737
|
+
const arr = doc.$get(path);
|
|
2738
|
+
if (arr && arr.length) {
|
|
2739
|
+
for (const subdoc of arr) {
|
|
2740
|
+
if (subdoc) {
|
|
2741
|
+
topLevelSubdocs.push(subdoc);
|
|
2742
|
+
}
|
|
2743
|
+
}
|
|
2744
|
+
}
|
|
2745
|
+
}
|
|
2746
|
+
}
|
|
2726
2747
|
const modifiedPaths = doc.modifiedPaths();
|
|
2727
|
-
for (const subdoc of
|
|
2748
|
+
for (const subdoc of topLevelSubdocs) {
|
|
2728
2749
|
if (subdoc.$basePath) {
|
|
2729
|
-
const fullPathToSubdoc = subdoc.$
|
|
2750
|
+
const fullPathToSubdoc = subdoc.$__pathRelativeToParent();
|
|
2730
2751
|
|
|
2731
2752
|
// Remove child paths for now, because we'll be validating the whole
|
|
2732
2753
|
// subdoc.
|
|
@@ -2736,11 +2757,12 @@ function _getPathsToValidate(doc, pathsToValidate, pathsToSkip, isNestedValidate
|
|
|
2736
2757
|
paths.delete(fullPathToSubdoc + '.' + modifiedPath);
|
|
2737
2758
|
}
|
|
2738
2759
|
|
|
2760
|
+
const subdocParent = subdoc.$parent();
|
|
2739
2761
|
if (doc.$isModified(fullPathToSubdoc, null, modifiedPaths) &&
|
|
2740
2762
|
// Avoid using isDirectModified() here because that does additional checks on whether the parent path
|
|
2741
2763
|
// is direct modified, which can cause performance issues re: gh-14897
|
|
2742
|
-
!
|
|
2743
|
-
!
|
|
2764
|
+
!subdocParent.$__.activePaths.getStatePaths('modify').hasOwnProperty(fullPathToSubdoc) &&
|
|
2765
|
+
!subdocParent.$isDefault(fullPathToSubdoc)) {
|
|
2744
2766
|
paths.add(fullPathToSubdoc);
|
|
2745
2767
|
|
|
2746
2768
|
if (doc.$__.pathsToScopes == null) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mongoose",
|
|
3
3
|
"description": "Mongoose MongoDB ODM",
|
|
4
|
-
"version": "8.13.
|
|
4
|
+
"version": "8.13.2",
|
|
5
5
|
"author": "Guillermo Rauch <guillermo@learnboost.com>",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"mongodb",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"sift": "17.1.3"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@babel/core": "7.26.
|
|
32
|
+
"@babel/core": "7.26.10",
|
|
33
33
|
"@babel/preset-env": "7.26.9",
|
|
34
34
|
"@typescript-eslint/eslint-plugin": "^8.19.1",
|
|
35
35
|
"@typescript-eslint/parser": "^8.19.1",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"nyc": "15.1.0",
|
|
63
63
|
"pug": "3.0.3",
|
|
64
64
|
"q": "1.5.1",
|
|
65
|
-
"sinon": "
|
|
65
|
+
"sinon": "20.0.0",
|
|
66
66
|
"stream-browserify": "3.0.0",
|
|
67
67
|
"tsd": "0.31.2",
|
|
68
68
|
"typescript": "5.7.3",
|