mongoose 8.6.2 → 8.6.4
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/index.js +1 -0
- package/lib/cast.js +11 -1
- package/lib/constants.js +37 -0
- package/lib/document.js +35 -64
- package/lib/error/browserMissingSchema.js +4 -3
- package/lib/error/divergentArray.js +7 -5
- package/lib/error/invalidSchemaOption.js +7 -5
- package/lib/error/missingSchema.js +7 -5
- package/lib/error/notFound.js +6 -4
- package/lib/error/objectExpected.js +8 -7
- package/lib/error/objectParameter.js +11 -9
- package/lib/error/overwriteModel.js +6 -5
- package/lib/error/parallelSave.js +9 -6
- package/lib/error/parallelValidate.js +8 -6
- package/lib/error/setOptionError.js +8 -6
- package/lib/error/strict.js +11 -9
- package/lib/error/strictPopulate.js +10 -8
- package/lib/error/validation.js +9 -7
- package/lib/error/validator.js +8 -7
- package/lib/error/version.js +10 -8
- package/lib/helpers/model/applyStaticHooks.js +14 -5
- package/lib/helpers/projection/isExclusive.js +6 -3
- package/lib/helpers/projection/isInclusive.js +2 -1
- package/lib/schema/uuid.js +10 -15
- package/package.json +1 -1
- package/types/document.d.ts +1 -1
package/lib/schema/uuid.js
CHANGED
|
@@ -26,19 +26,6 @@ function hex2buffer(hex) {
|
|
|
26
26
|
return buff;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
/**
|
|
30
|
-
* Helper function to convert the buffer input to a string
|
|
31
|
-
* @param {Buffer} buf The buffer to convert to a hex-string
|
|
32
|
-
* @returns {String} The buffer as a hex-string
|
|
33
|
-
* @api private
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
function binary2hex(buf) {
|
|
37
|
-
// use buffer built-in function to convert from buffer to hex-string
|
|
38
|
-
const hex = buf != null && buf.toString('hex');
|
|
39
|
-
return hex;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
29
|
/**
|
|
43
30
|
* Convert a String to Binary
|
|
44
31
|
* @param {String} uuidStr The value to process
|
|
@@ -67,7 +54,7 @@ function binaryToString(uuidBin) {
|
|
|
67
54
|
// i(hasezoey) dont quite know why, but "uuidBin" may sometimes also be the already processed string
|
|
68
55
|
let hex;
|
|
69
56
|
if (typeof uuidBin !== 'string' && uuidBin != null) {
|
|
70
|
-
hex =
|
|
57
|
+
hex = uuidBin.toString('hex');
|
|
71
58
|
const uuidStr = hex.substring(0, 8) + '-' + hex.substring(8, 8 + 4) + '-' + hex.substring(12, 12 + 4) + '-' + hex.substring(16, 16 + 4) + '-' + hex.substring(20, 20 + 12);
|
|
72
59
|
return uuidStr;
|
|
73
60
|
}
|
|
@@ -90,7 +77,15 @@ function SchemaUUID(key, options) {
|
|
|
90
77
|
if (value != null && value.$__ != null) {
|
|
91
78
|
return value;
|
|
92
79
|
}
|
|
93
|
-
|
|
80
|
+
if (Buffer.isBuffer(value)) {
|
|
81
|
+
return binaryToString(value);
|
|
82
|
+
} else if (value instanceof Binary) {
|
|
83
|
+
return binaryToString(value.buffer);
|
|
84
|
+
} else if (utils.isPOJO(value) && value.type === 'Buffer' && Array.isArray(value.data)) {
|
|
85
|
+
// Cloned buffers look like `{ type: 'Buffer', data: [5, 224, ...] }`
|
|
86
|
+
return binaryToString(Buffer.from(value.data));
|
|
87
|
+
}
|
|
88
|
+
return value;
|
|
94
89
|
});
|
|
95
90
|
}
|
|
96
91
|
|
package/package.json
CHANGED
package/types/document.d.ts
CHANGED
|
@@ -138,7 +138,7 @@ declare module 'mongoose' {
|
|
|
138
138
|
* Takes a populated field and returns it to its unpopulated state. If called with
|
|
139
139
|
* no arguments, then all populated fields are returned to their unpopulated state.
|
|
140
140
|
*/
|
|
141
|
-
depopulate(path?: string | string[]): this
|
|
141
|
+
depopulate<Paths = {}>(path?: string | string[]): MergeType<this, Paths>;
|
|
142
142
|
|
|
143
143
|
/**
|
|
144
144
|
* Returns the list of paths that have been directly modified. A direct
|