mongoose 8.24.10 → 8.24.12
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 +5 -2
- package/lib/error/validator.js +12 -1
- package/package.json +1 -1
package/lib/document.js
CHANGED
|
@@ -1769,8 +1769,11 @@ Document.prototype.$__set = function(pathToMark, path, options, constructing, pa
|
|
|
1769
1769
|
let value = isMap ? obj.get(parts[i]) : obj[parts[i]];
|
|
1770
1770
|
// Skip inherited properties like `Object.prototype.toString`, document methods,
|
|
1771
1771
|
// or document internals like `$__schema` to avoid setting properties on shared
|
|
1772
|
-
// objects. Document properties are getters on the prototype, so
|
|
1773
|
-
|
|
1772
|
+
// objects. Document properties are getters on the prototype, so read raw values
|
|
1773
|
+
// from `_doc`. Nested properties have a `$__` but their `_doc` is their parent's
|
|
1774
|
+
// `_doc`.
|
|
1775
|
+
const raw = obj.$__ != null && !obj.$__isNested ? obj._doc : obj;
|
|
1776
|
+
if (!isMap && !Object.hasOwn(raw, parts[i]) && parts[i] in obj) {
|
|
1774
1777
|
return;
|
|
1775
1778
|
}
|
|
1776
1779
|
if (utils.isPOJO(value)) {
|
package/lib/error/validator.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
'use strict';
|
|
6
6
|
|
|
7
7
|
const MongooseError = require('./mongooseError');
|
|
8
|
+
const util = require('util');
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Schema validator error
|
|
@@ -87,7 +88,17 @@ function formatMessage(msg, properties, doc) {
|
|
|
87
88
|
if (propertyName === 'message') {
|
|
88
89
|
continue;
|
|
89
90
|
}
|
|
90
|
-
|
|
91
|
+
const token = '{' + propertyName.toUpperCase() + '}';
|
|
92
|
+
if (!msg.includes(token)) {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
let value;
|
|
96
|
+
try {
|
|
97
|
+
value = String(properties[propertyName]);
|
|
98
|
+
} catch {
|
|
99
|
+
value = util.inspect(properties[propertyName]);
|
|
100
|
+
}
|
|
101
|
+
msg = msg.replace(token, value);
|
|
91
102
|
}
|
|
92
103
|
|
|
93
104
|
return msg;
|