mongoose 8.6.1 → 8.6.3
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/connection.js +3 -0
- package/lib/cursor/queryCursor.js +1 -1
- package/lib/document.js +1 -1
- package/lib/drivers/node-mongodb-native/connection.js +1 -1
- package/lib/plugins/trackTransaction.js +0 -7
- package/lib/schema/uuid.js +10 -15
- package/package.json +1 -1
- package/types/cursor.d.ts +1 -0
- package/types/document.d.ts +1 -1
- package/types/inferrawdoctype.d.ts +2 -2
- package/types/inferschematype.d.ts +2 -2
- package/types/query.d.ts +3 -5
- package/types/schematypes.d.ts +3 -0
package/index.js
CHANGED
|
@@ -28,6 +28,7 @@ module.exports.modelNames = mongoose.modelNames;
|
|
|
28
28
|
module.exports.plugin = mongoose.plugin;
|
|
29
29
|
module.exports.connections = mongoose.connections;
|
|
30
30
|
module.exports.version = mongoose.version;
|
|
31
|
+
module.exports.Aggregate = mongoose.Aggregate;
|
|
31
32
|
module.exports.Mongoose = mongoose.Mongoose;
|
|
32
33
|
module.exports.Schema = mongoose.Schema;
|
|
33
34
|
module.exports.SchemaType = mongoose.SchemaType;
|
package/lib/connection.js
CHANGED
|
@@ -71,6 +71,9 @@ function Connection(base) {
|
|
|
71
71
|
} else {
|
|
72
72
|
this.id = base.nextConnectionId;
|
|
73
73
|
}
|
|
74
|
+
|
|
75
|
+
// Internal queue of objects `{ fn, ctx, args }` that Mongoose calls when this connection is successfully
|
|
76
|
+
// opened. In `onOpen()`, Mongoose calls every entry in `_queue` and empties the queue.
|
|
74
77
|
this._queue = [];
|
|
75
78
|
}
|
|
76
79
|
|
|
@@ -10,7 +10,7 @@ const eachAsync = require('../helpers/cursor/eachAsync');
|
|
|
10
10
|
const helpers = require('../queryHelpers');
|
|
11
11
|
const kareem = require('kareem');
|
|
12
12
|
const immediate = require('../helpers/immediate');
|
|
13
|
-
const { once } = require('
|
|
13
|
+
const { once } = require('events');
|
|
14
14
|
const util = require('util');
|
|
15
15
|
|
|
16
16
|
/**
|
package/lib/document.js
CHANGED
|
@@ -1213,7 +1213,7 @@ Document.prototype.$set = function $set(path, val, type, options) {
|
|
|
1213
1213
|
this.$__setValue(path, null);
|
|
1214
1214
|
cleanModifiedSubpaths(this, path);
|
|
1215
1215
|
} else {
|
|
1216
|
-
return this.$set(val, path, constructing);
|
|
1216
|
+
return this.$set(val, path, constructing, options);
|
|
1217
1217
|
}
|
|
1218
1218
|
|
|
1219
1219
|
const keys = getKeysInSchemaOrder(this.$__schema, val, path);
|
|
@@ -27,13 +27,6 @@ module.exports = function trackTransaction(schema) {
|
|
|
27
27
|
initialState.atomics = _getAtomics(this);
|
|
28
28
|
|
|
29
29
|
session[sessionNewDocuments].set(this, initialState);
|
|
30
|
-
} else {
|
|
31
|
-
const state = session[sessionNewDocuments].get(this);
|
|
32
|
-
|
|
33
|
-
for (const path of Object.keys(this.$__.activePaths.getStatePaths('modify'))) {
|
|
34
|
-
state.modifiedPaths.add(path);
|
|
35
|
-
}
|
|
36
|
-
state.atomics = _getAtomics(this, state.atomics);
|
|
37
30
|
}
|
|
38
31
|
});
|
|
39
32
|
};
|
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/cursor.d.ts
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
|
|
@@ -91,8 +91,8 @@ declare module 'mongoose' {
|
|
|
91
91
|
IfEquals<PathValueType, String> extends true ? PathEnumOrString<Options['enum']> :
|
|
92
92
|
PathValueType extends NumberSchemaDefinition ? Options['enum'] extends ReadonlyArray<any> ? Options['enum'][number] : number :
|
|
93
93
|
IfEquals<PathValueType, Schema.Types.Number> extends true ? number :
|
|
94
|
-
PathValueType extends DateSchemaDefinition ?
|
|
95
|
-
IfEquals<PathValueType, Schema.Types.Date> extends true ?
|
|
94
|
+
PathValueType extends DateSchemaDefinition ? NativeDate :
|
|
95
|
+
IfEquals<PathValueType, Schema.Types.Date> extends true ? NativeDate :
|
|
96
96
|
PathValueType extends typeof Buffer | 'buffer' | 'Buffer' | typeof Schema.Types.Buffer ? Buffer :
|
|
97
97
|
PathValueType extends BooleanSchemaDefinition ? boolean :
|
|
98
98
|
IfEquals<PathValueType, Schema.Types.Boolean> extends true ? boolean :
|
|
@@ -281,8 +281,8 @@ type ResolvePathType<PathValueType, Options extends SchemaTypeOptions<PathValueT
|
|
|
281
281
|
IfEquals<PathValueType, String> extends true ? PathEnumOrString<Options['enum']> :
|
|
282
282
|
PathValueType extends NumberSchemaDefinition ? Options['enum'] extends ReadonlyArray<any> ? Options['enum'][number] : number :
|
|
283
283
|
IfEquals<PathValueType, Schema.Types.Number> extends true ? number :
|
|
284
|
-
PathValueType extends DateSchemaDefinition ?
|
|
285
|
-
IfEquals<PathValueType, Schema.Types.Date> extends true ?
|
|
284
|
+
PathValueType extends DateSchemaDefinition ? NativeDate :
|
|
285
|
+
IfEquals<PathValueType, Schema.Types.Date> extends true ? NativeDate :
|
|
286
286
|
PathValueType extends typeof Buffer | 'buffer' | 'Buffer' | typeof Schema.Types.Buffer ? Buffer :
|
|
287
287
|
PathValueType extends BooleanSchemaDefinition ? boolean :
|
|
288
288
|
IfEquals<PathValueType, Schema.Types.Boolean> extends true ? boolean :
|
package/types/query.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ declare module 'mongoose' {
|
|
|
12
12
|
*/
|
|
13
13
|
type RootFilterQuery<T> = FilterQuery<T> | Query<any, any> | Types.ObjectId;
|
|
14
14
|
|
|
15
|
-
type FilterQuery<T> ={
|
|
15
|
+
type FilterQuery<T> = {
|
|
16
16
|
[P in keyof T]?: Condition<T[P]>;
|
|
17
17
|
} & RootQuerySelector<T> & { _id?: Condition<string>; };
|
|
18
18
|
|
|
@@ -117,10 +117,8 @@ declare module 'mongoose' {
|
|
|
117
117
|
/** @see https://www.mongodb.com/docs/manual/reference/operator/query/comment/#op._S_comment */
|
|
118
118
|
$comment?: string;
|
|
119
119
|
$expr?: Record<string, any>;
|
|
120
|
-
//
|
|
121
|
-
|
|
122
|
-
// they include a "." (to avoid generically allowing any unexpected keys)
|
|
123
|
-
[nestedSelector: `${string}.${string}`]: any;
|
|
120
|
+
// this will mark all unrecognized properties as any (including nested queries)
|
|
121
|
+
[key: string]: any;
|
|
124
122
|
};
|
|
125
123
|
|
|
126
124
|
interface QueryTimestampsConfig {
|
package/types/schematypes.d.ts
CHANGED
|
@@ -216,6 +216,9 @@ declare module 'mongoose' {
|
|
|
216
216
|
/** Attaches a getter for all instances of this schema type. */
|
|
217
217
|
static get(getter: (value: any) => any): void;
|
|
218
218
|
|
|
219
|
+
/** Array containing default setters for all instances of this SchemaType */
|
|
220
|
+
static setters: ((val?: unknown, priorVal?: unknown, doc?: Document<unknown>, options?: Record<string, any> | null) => unknown)[];
|
|
221
|
+
|
|
219
222
|
/** The class that Mongoose uses internally to instantiate this SchemaType's `options` property. */
|
|
220
223
|
OptionsConstructor: SchemaTypeOptions<T>;
|
|
221
224
|
|