mongoose 8.19.4 → 9.0.0-rc0
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/eslint.config.mjs +198 -0
- package/lib/aggregate.js +17 -73
- package/lib/cast/bigint.js +1 -1
- package/lib/cast/double.js +1 -1
- package/lib/cast/uuid.js +5 -48
- package/lib/cast.js +3 -3
- package/lib/connection.js +0 -1
- package/lib/cursor/aggregationCursor.js +14 -24
- package/lib/cursor/queryCursor.js +7 -14
- package/lib/document.js +125 -121
- package/lib/drivers/node-mongodb-native/connection.js +3 -10
- package/lib/error/divergentArray.js +2 -2
- package/lib/error/objectParameter.js +1 -2
- package/lib/error/validation.js +0 -8
- package/lib/helpers/clone.js +1 -1
- package/lib/helpers/common.js +1 -1
- package/lib/helpers/discriminator/mergeDiscriminatorSchema.js +10 -0
- package/lib/helpers/indexes/isIndexEqual.js +0 -1
- package/lib/helpers/model/applyDefaultsToPOJO.js +2 -2
- package/lib/helpers/model/applyHooks.js +43 -53
- package/lib/helpers/model/applyMethods.js +2 -2
- package/lib/helpers/model/applyStaticHooks.js +1 -48
- package/lib/helpers/model/castBulkWrite.js +1 -1
- package/lib/helpers/parallelLimit.js +18 -36
- package/lib/helpers/pluralize.js +3 -3
- package/lib/helpers/populate/assignRawDocsToIdStructure.js +1 -8
- package/lib/helpers/populate/createPopulateQueryFilter.js +1 -1
- package/lib/helpers/populate/getModelsMapForPopulate.js +17 -9
- package/lib/helpers/populate/getSchemaTypes.js +5 -5
- package/lib/helpers/query/cast$expr.js +8 -10
- package/lib/helpers/query/castFilterPath.js +1 -1
- package/lib/helpers/query/castUpdate.js +15 -13
- package/lib/helpers/query/getEmbeddedDiscriminatorPath.js +1 -1
- package/lib/helpers/schema/applyPlugins.js +1 -1
- package/lib/helpers/schema/getIndexes.js +1 -7
- package/lib/helpers/timestamps/setupTimestamps.js +3 -6
- package/lib/helpers/updateValidators.js +57 -111
- package/lib/model.js +419 -607
- package/lib/mongoose.js +41 -13
- package/lib/plugins/saveSubdocs.js +24 -51
- package/lib/plugins/sharding.js +5 -4
- package/lib/plugins/validateBeforeSave.js +3 -13
- package/lib/query.js +101 -145
- package/lib/queryHelpers.js +2 -2
- package/lib/schema/array.js +46 -84
- package/lib/schema/bigint.js +4 -2
- package/lib/schema/boolean.js +4 -2
- package/lib/schema/buffer.js +4 -2
- package/lib/schema/date.js +4 -2
- package/lib/schema/decimal128.js +4 -2
- package/lib/schema/documentArray.js +66 -91
- package/lib/schema/documentArrayElement.js +18 -11
- package/lib/schema/double.js +4 -2
- package/lib/schema/int32.js +4 -2
- package/lib/schema/map.js +87 -6
- package/lib/schema/mixed.js +4 -2
- package/lib/schema/number.js +4 -2
- package/lib/schema/objectId.js +4 -2
- package/lib/schema/string.js +5 -3
- package/lib/schema/subdocument.js +27 -31
- package/lib/schema/union.js +11 -3
- package/lib/schema/uuid.js +4 -23
- package/lib/schema.js +91 -91
- package/lib/schemaType.js +67 -59
- package/lib/types/array/index.js +2 -2
- package/lib/types/array/methods/index.js +4 -4
- package/lib/types/arraySubdocument.js +1 -1
- package/lib/types/buffer.js +10 -10
- package/lib/types/decimal128.js +1 -1
- package/lib/types/documentArray/index.js +1 -1
- package/lib/types/documentArray/methods/index.js +32 -18
- package/lib/types/double.js +1 -1
- package/lib/types/map.js +1 -2
- package/lib/types/objectid.js +1 -1
- package/lib/types/subdocument.js +15 -43
- package/lib/types/uuid.js +1 -1
- package/lib/utils.js +1 -8
- package/lib/validOptions.js +3 -3
- package/package.json +11 -24
- package/types/connection.d.ts +20 -11
- package/types/document.d.ts +96 -27
- package/types/index.d.ts +143 -39
- package/types/inferhydrateddoctype.d.ts +115 -0
- package/types/inferrawdoctype.d.ts +99 -75
- package/types/inferschematype.d.ts +17 -3
- package/types/middlewares.d.ts +0 -2
- package/types/models.d.ts +131 -199
- package/types/mongooseoptions.d.ts +6 -5
- package/types/pipelinestage.d.ts +1 -1
- package/types/query.d.ts +71 -139
- package/types/schemaoptions.d.ts +1 -1
- package/types/schematypes.d.ts +14 -10
- package/types/types.d.ts +3 -4
- package/types/utility.d.ts +68 -48
- package/types/validation.d.ts +18 -14
- package/browser.js +0 -8
- package/dist/browser.umd.js +0 -2
- package/lib/browser.js +0 -141
- package/lib/browserDocument.js +0 -101
- package/lib/documentProvider.js +0 -30
- package/lib/drivers/browser/binary.js +0 -14
- package/lib/drivers/browser/decimal128.js +0 -7
- package/lib/drivers/browser/index.js +0 -13
- package/lib/drivers/browser/objectid.js +0 -29
- package/lib/helpers/promiseOrCallback.js +0 -54
package/lib/types/buffer.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
'use strict';
|
|
6
6
|
|
|
7
|
-
const Binary = require('bson').Binary;
|
|
8
|
-
const UUID = require('bson').UUID;
|
|
7
|
+
const Binary = require('mongodb/lib/bson').Binary;
|
|
8
|
+
const UUID = require('mongodb/lib/bson').UUID;
|
|
9
9
|
const utils = require('../utils');
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -169,14 +169,14 @@ utils.each(
|
|
|
169
169
|
*
|
|
170
170
|
* #### SubTypes:
|
|
171
171
|
*
|
|
172
|
-
* const
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
* doc.buffer.toObject(
|
|
172
|
+
* const mongodb = require('mongodb')
|
|
173
|
+
* mongodb.BSON.BSON_BINARY_SUBTYPE_DEFAULT
|
|
174
|
+
* mongodb.BSON.BSON_BINARY_SUBTYPE_FUNCTION
|
|
175
|
+
* mongodb.BSON.BSON_BINARY_SUBTYPE_BYTE_ARRAY
|
|
176
|
+
* mongodb.BSON.BSON_BINARY_SUBTYPE_UUID
|
|
177
|
+
* mongodb.BSON.BSON_BINARY_SUBTYPE_MD5
|
|
178
|
+
* mongodb.BSON.BSON_BINARY_SUBTYPE_USER_DEFINED
|
|
179
|
+
* doc.buffer.toObject(mongodb.BSON.BSON_BINARY_SUBTYPE_USER_DEFINED);
|
|
180
180
|
*
|
|
181
181
|
* @see bsonspec https://bsonspec.org/#/specification
|
|
182
182
|
* @param {Hex} [subtype]
|
package/lib/types/decimal128.js
CHANGED
|
@@ -61,7 +61,7 @@ function MongooseDocumentArray(values, path, doc, schematype) {
|
|
|
61
61
|
while (internals[arraySchemaSymbol] != null &&
|
|
62
62
|
internals[arraySchemaSymbol].$isMongooseArray &&
|
|
63
63
|
!internals[arraySchemaSymbol].$isMongooseDocumentArray) {
|
|
64
|
-
internals[arraySchemaSymbol] = internals[arraySchemaSymbol].
|
|
64
|
+
internals[arraySchemaSymbol] = internals[arraySchemaSymbol].embeddedSchemaType;
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
const ArrayMethods = require('../../array/methods');
|
|
4
4
|
const Document = require('../../../document');
|
|
5
|
-
const castObjectId = require('../../../cast/objectid');
|
|
6
5
|
const getDiscriminatorByValue = require('../../../helpers/discriminator/getDiscriminatorByValue');
|
|
7
6
|
const internalToObjectOptions = require('../../../options').internalToObjectOptions;
|
|
8
7
|
const utils = require('../../../utils');
|
|
@@ -60,7 +59,7 @@ const methods = {
|
|
|
60
59
|
if (this[arraySchemaSymbol] == null) {
|
|
61
60
|
return value;
|
|
62
61
|
}
|
|
63
|
-
let Constructor = this[arraySchemaSymbol].
|
|
62
|
+
let Constructor = this[arraySchemaSymbol].Constructor;
|
|
64
63
|
const isInstance = Constructor.$isMongooseDocumentArray ?
|
|
65
64
|
utils.isMongooseDocumentArray(value) :
|
|
66
65
|
value instanceof Constructor;
|
|
@@ -121,23 +120,36 @@ const methods = {
|
|
|
121
120
|
*
|
|
122
121
|
* @return {EmbeddedDocument|null} the subdocument or null if not found.
|
|
123
122
|
* @param {ObjectId|String|Number|Buffer} id
|
|
124
|
-
* @TODO cast to the _id based on schema for proper comparison
|
|
125
123
|
* @method id
|
|
126
124
|
* @api public
|
|
127
125
|
* @memberOf MongooseDocumentArray
|
|
128
126
|
*/
|
|
129
127
|
|
|
130
128
|
id(id) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
129
|
+
if (id == null) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
134
132
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
133
|
+
const schemaType = this[arraySchemaSymbol];
|
|
134
|
+
let idSchemaType = null;
|
|
135
|
+
|
|
136
|
+
if (schemaType && schemaType.schema) {
|
|
137
|
+
idSchemaType = schemaType.schema.path('_id');
|
|
138
|
+
} else if (schemaType && schemaType.casterConstructor && schemaType.casterConstructor.schema) {
|
|
139
|
+
idSchemaType = schemaType.casterConstructor.schema.path('_id');
|
|
139
140
|
}
|
|
140
141
|
|
|
142
|
+
let castedId = null;
|
|
143
|
+
if (idSchemaType) {
|
|
144
|
+
try {
|
|
145
|
+
castedId = idSchemaType.cast(id);
|
|
146
|
+
} catch {
|
|
147
|
+
// ignore error
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
let _id;
|
|
152
|
+
|
|
141
153
|
for (const val of this) {
|
|
142
154
|
if (!val) {
|
|
143
155
|
continue;
|
|
@@ -145,18 +157,20 @@ const methods = {
|
|
|
145
157
|
|
|
146
158
|
_id = val.get('_id');
|
|
147
159
|
|
|
148
|
-
if (_id
|
|
160
|
+
if (_id == null) {
|
|
149
161
|
continue;
|
|
150
162
|
} else if (_id instanceof Document) {
|
|
151
|
-
|
|
152
|
-
if (
|
|
163
|
+
_id = _id.get('_id');
|
|
164
|
+
if (castedId != null && utils.deepEqual(castedId, _id)) {
|
|
153
165
|
return val;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
if (id == _id || utils.deepEqual(id, _id)) {
|
|
166
|
+
} else if (castedId == null && (id == _id || utils.deepEqual(id, _id))) {
|
|
167
|
+
// Backwards compat: compare user-specified param to _id using loose equality
|
|
157
168
|
return val;
|
|
158
169
|
}
|
|
159
|
-
} else if (
|
|
170
|
+
} else if (castedId != null && utils.deepEqual(castedId, _id)) {
|
|
171
|
+
return val;
|
|
172
|
+
} else if (castedId == null && (_id == id || utils.deepEqual(id, _id))) {
|
|
173
|
+
// Backwards compat: compare user-specified param to _id using loose equality
|
|
160
174
|
return val;
|
|
161
175
|
}
|
|
162
176
|
}
|
|
@@ -280,7 +294,7 @@ const methods = {
|
|
|
280
294
|
*/
|
|
281
295
|
|
|
282
296
|
create(obj) {
|
|
283
|
-
let Constructor = this[arraySchemaSymbol].
|
|
297
|
+
let Constructor = this[arraySchemaSymbol].Constructor;
|
|
284
298
|
if (obj &&
|
|
285
299
|
Constructor.discriminators &&
|
|
286
300
|
Constructor.schema &&
|
package/lib/types/double.js
CHANGED
package/lib/types/map.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const Mixed = require('../schema/mixed');
|
|
4
3
|
const MongooseError = require('../error/mongooseError');
|
|
5
4
|
const clone = require('../helpers/clone');
|
|
6
5
|
const deepEqual = require('../utils').deepEqual;
|
|
@@ -41,7 +40,7 @@ class MongooseMap extends Map {
|
|
|
41
40
|
this.$__pathRelativeToParent = null;
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
this.$__schemaType = schemaType
|
|
43
|
+
this.$__schemaType = schemaType;
|
|
45
44
|
|
|
46
45
|
this.$__runDeferred();
|
|
47
46
|
}
|
package/lib/types/objectid.js
CHANGED
package/lib/types/subdocument.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const Document = require('../document');
|
|
4
|
-
const immediate = require('../helpers/immediate');
|
|
5
4
|
const internalToObjectOptions = require('../options').internalToObjectOptions;
|
|
6
5
|
const util = require('util');
|
|
7
6
|
const utils = require('../utils');
|
|
@@ -15,11 +14,7 @@ module.exports = Subdocument;
|
|
|
15
14
|
* @api private
|
|
16
15
|
*/
|
|
17
16
|
|
|
18
|
-
function Subdocument(value, fields, parent,
|
|
19
|
-
if (typeof skipId === 'object' && skipId != null && options == null) {
|
|
20
|
-
options = skipId;
|
|
21
|
-
skipId = undefined;
|
|
22
|
-
}
|
|
17
|
+
function Subdocument(value, fields, parent, options) {
|
|
23
18
|
if (parent != null) {
|
|
24
19
|
// If setting a nested path, should copy isNew from parent re: gh-7048
|
|
25
20
|
const parentOptions = { isNew: parent.isNew };
|
|
@@ -45,7 +40,7 @@ function Subdocument(value, fields, parent, skipId, options) {
|
|
|
45
40
|
delete documentOptions.path;
|
|
46
41
|
}
|
|
47
42
|
|
|
48
|
-
Document.call(this, value, fields,
|
|
43
|
+
Document.call(this, value, fields, documentOptions);
|
|
49
44
|
|
|
50
45
|
delete this.$__.priorDoc;
|
|
51
46
|
}
|
|
@@ -94,14 +89,7 @@ Subdocument.prototype.save = async function save(options) {
|
|
|
94
89
|
'if you\'re sure this behavior is right for your app.');
|
|
95
90
|
}
|
|
96
91
|
|
|
97
|
-
return
|
|
98
|
-
this.$__save((err) => {
|
|
99
|
-
if (err != null) {
|
|
100
|
-
return reject(err);
|
|
101
|
-
}
|
|
102
|
-
resolve(this);
|
|
103
|
-
});
|
|
104
|
-
});
|
|
92
|
+
return await this.$__save();
|
|
105
93
|
};
|
|
106
94
|
|
|
107
95
|
/**
|
|
@@ -164,8 +152,15 @@ Subdocument.prototype.$__pathRelativeToParent = function(p) {
|
|
|
164
152
|
* @api private
|
|
165
153
|
*/
|
|
166
154
|
|
|
167
|
-
Subdocument.prototype.$__save = function(
|
|
168
|
-
|
|
155
|
+
Subdocument.prototype.$__save = async function $__save() {
|
|
156
|
+
try {
|
|
157
|
+
await this._execDocumentPreHooks('save');
|
|
158
|
+
} catch (error) {
|
|
159
|
+
await this._execDocumentPostHooks('save', error);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
await this._execDocumentPostHooks('save');
|
|
169
164
|
};
|
|
170
165
|
|
|
171
166
|
/*!
|
|
@@ -286,7 +281,7 @@ Subdocument.prototype.ownerDocument = function() {
|
|
|
286
281
|
return this.$__.ownerDocument;
|
|
287
282
|
}
|
|
288
283
|
|
|
289
|
-
let parent = this;
|
|
284
|
+
let parent = this;
|
|
290
285
|
const paths = [];
|
|
291
286
|
const seenDocs = new Set([parent]);
|
|
292
287
|
|
|
@@ -318,7 +313,7 @@ Subdocument.prototype.ownerDocument = function() {
|
|
|
318
313
|
*/
|
|
319
314
|
|
|
320
315
|
Subdocument.prototype.$__fullPathWithIndexes = function() {
|
|
321
|
-
let parent = this;
|
|
316
|
+
let parent = this;
|
|
322
317
|
const paths = [];
|
|
323
318
|
const seenDocs = new Set([parent]);
|
|
324
319
|
|
|
@@ -361,22 +356,6 @@ Subdocument.prototype.parent = function() {
|
|
|
361
356
|
|
|
362
357
|
Subdocument.prototype.$parent = Subdocument.prototype.parent;
|
|
363
358
|
|
|
364
|
-
/**
|
|
365
|
-
* no-op for hooks
|
|
366
|
-
* @param {Function} cb
|
|
367
|
-
* @method $__deleteOne
|
|
368
|
-
* @memberOf Subdocument
|
|
369
|
-
* @instance
|
|
370
|
-
* @api private
|
|
371
|
-
*/
|
|
372
|
-
|
|
373
|
-
Subdocument.prototype.$__deleteOne = function(cb) {
|
|
374
|
-
if (cb == null) {
|
|
375
|
-
return;
|
|
376
|
-
}
|
|
377
|
-
return cb(null, this);
|
|
378
|
-
};
|
|
379
|
-
|
|
380
359
|
/**
|
|
381
360
|
* ignore
|
|
382
361
|
* @method $__removeFromParent
|
|
@@ -393,14 +372,9 @@ Subdocument.prototype.$__removeFromParent = function() {
|
|
|
393
372
|
* Null-out this subdoc
|
|
394
373
|
*
|
|
395
374
|
* @param {Object} [options]
|
|
396
|
-
* @param {Function} [callback] optional callback for compatibility with Document.prototype.remove
|
|
397
375
|
*/
|
|
398
376
|
|
|
399
|
-
Subdocument.prototype.deleteOne = function(options
|
|
400
|
-
if (typeof options === 'function') {
|
|
401
|
-
callback = options;
|
|
402
|
-
options = null;
|
|
403
|
-
}
|
|
377
|
+
Subdocument.prototype.deleteOne = function deleteOne(options) {
|
|
404
378
|
registerRemoveListener(this);
|
|
405
379
|
|
|
406
380
|
// If removing entire doc, no need to remove subdoc
|
|
@@ -411,8 +385,6 @@ Subdocument.prototype.deleteOne = function(options, callback) {
|
|
|
411
385
|
owner.$__.removedSubdocs = owner.$__.removedSubdocs || [];
|
|
412
386
|
owner.$__.removedSubdocs.push(this);
|
|
413
387
|
}
|
|
414
|
-
|
|
415
|
-
return this.$__deleteOne(callback);
|
|
416
388
|
};
|
|
417
389
|
|
|
418
390
|
/*!
|
package/lib/types/uuid.js
CHANGED
package/lib/utils.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Module dependencies.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
const UUID = require('bson').UUID;
|
|
7
|
+
const UUID = require('mongodb/lib/bson').UUID;
|
|
8
8
|
const ms = require('ms');
|
|
9
9
|
const mpath = require('mpath');
|
|
10
10
|
const ObjectId = require('./types/objectid');
|
|
@@ -18,7 +18,6 @@ const isBsonType = require('./helpers/isBsonType');
|
|
|
18
18
|
const isPOJO = require('./helpers/isPOJO');
|
|
19
19
|
const getFunctionName = require('./helpers/getFunctionName');
|
|
20
20
|
const isMongooseObject = require('./helpers/isMongooseObject');
|
|
21
|
-
const promiseOrCallback = require('./helpers/promiseOrCallback');
|
|
22
21
|
const schemaMerge = require('./helpers/schema/merge');
|
|
23
22
|
const specialProperties = require('./helpers/specialProperties');
|
|
24
23
|
const { trustedSymbol } = require('./helpers/query/trusted');
|
|
@@ -197,12 +196,6 @@ exports.last = function(arr) {
|
|
|
197
196
|
return void 0;
|
|
198
197
|
};
|
|
199
198
|
|
|
200
|
-
/*!
|
|
201
|
-
* ignore
|
|
202
|
-
*/
|
|
203
|
-
|
|
204
|
-
exports.promiseOrCallback = promiseOrCallback;
|
|
205
|
-
|
|
206
199
|
/*!
|
|
207
200
|
* ignore
|
|
208
201
|
*/
|
package/lib/validOptions.js
CHANGED
|
@@ -19,7 +19,6 @@ const VALID_OPTIONS = Object.freeze([
|
|
|
19
19
|
'debug',
|
|
20
20
|
'forceRepopulate',
|
|
21
21
|
'id',
|
|
22
|
-
'timestamps.createdAt.immutable',
|
|
23
22
|
'maxTimeMS',
|
|
24
23
|
'objectIdGetter',
|
|
25
24
|
'overwriteModels',
|
|
@@ -29,14 +28,15 @@ const VALID_OPTIONS = Object.freeze([
|
|
|
29
28
|
'sanitizeProjection',
|
|
30
29
|
'selectPopulatedPaths',
|
|
31
30
|
'setDefaultsOnInsert',
|
|
32
|
-
'skipOriginalStackTraces',
|
|
33
31
|
'strict',
|
|
34
32
|
'strictPopulate',
|
|
35
33
|
'strictQuery',
|
|
34
|
+
'timestamps.createdAt.immutable',
|
|
36
35
|
'toJSON',
|
|
37
36
|
'toObject',
|
|
38
37
|
'transactionAsyncLocalStorage',
|
|
39
|
-
'translateAliases'
|
|
38
|
+
'translateAliases',
|
|
39
|
+
'updatePipeline'
|
|
40
40
|
]);
|
|
41
41
|
|
|
42
42
|
module.exports = VALID_OPTIONS;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mongoose",
|
|
3
3
|
"description": "Mongoose MongoDB ODM",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "9.0.0-rc0",
|
|
5
5
|
"author": "Guillermo Rauch <guillermo@learnboost.com>",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"mongodb",
|
|
@@ -20,33 +20,24 @@
|
|
|
20
20
|
"type": "commonjs",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"mongodb": "~6.20.0",
|
|
23
|
+
"kareem": "3.0.0",
|
|
24
|
+
"mongodb": "~7.0",
|
|
26
25
|
"mpath": "0.9.0",
|
|
27
|
-
"mquery": "
|
|
26
|
+
"mquery": "6.0.0",
|
|
28
27
|
"ms": "2.1.3",
|
|
29
28
|
"sift": "17.1.3"
|
|
30
29
|
},
|
|
31
30
|
"devDependencies": {
|
|
32
31
|
"@ark/attest": "0.53.0",
|
|
33
|
-
"@babel/core": "7.28.5",
|
|
34
|
-
"@babel/preset-env": "7.28.5",
|
|
35
32
|
"@mongodb-js/mongodb-downloader": "^1.0.0",
|
|
36
|
-
"@typescript-eslint/eslint-plugin": "^8.19.1",
|
|
37
|
-
"@typescript-eslint/parser": "^8.19.1",
|
|
38
33
|
"acquit": "1.4.0",
|
|
39
34
|
"acquit-ignore": "0.2.1",
|
|
40
35
|
"acquit-require": "0.1.1",
|
|
41
36
|
"ajv": "8.17.1",
|
|
42
|
-
"assert-browserify": "2.0.0",
|
|
43
|
-
"babel-loader": "8.2.5",
|
|
44
37
|
"broken-link-checker": "^0.7.8",
|
|
45
|
-
"buffer": "^5.6.0",
|
|
46
38
|
"cheerio": "1.1.2",
|
|
47
|
-
"crypto-browserify": "3.12.1",
|
|
48
39
|
"dox": "1.0.0",
|
|
49
|
-
"eslint": "
|
|
40
|
+
"eslint": "9.25.1",
|
|
50
41
|
"eslint-plugin-markdown": "^5.1.0",
|
|
51
42
|
"eslint-plugin-mocha-no-only": "1.2.0",
|
|
52
43
|
"express": "^4.19.2",
|
|
@@ -61,16 +52,15 @@
|
|
|
61
52
|
"moment": "2.30.1",
|
|
62
53
|
"mongodb-memory-server": "10.3.0",
|
|
63
54
|
"mongodb-runner": "^6.0.0",
|
|
55
|
+
"mongodb-client-encryption": "~7.0",
|
|
64
56
|
"ncp": "^2.0.0",
|
|
65
57
|
"nyc": "15.1.0",
|
|
66
58
|
"pug": "3.0.3",
|
|
67
|
-
"q": "1.5.1",
|
|
68
59
|
"sinon": "21.0.0",
|
|
69
|
-
"stream-browserify": "3.0.0",
|
|
70
60
|
"tsd": "0.33.0",
|
|
71
61
|
"typescript": "5.9.3",
|
|
72
|
-
"
|
|
73
|
-
"
|
|
62
|
+
"typescript-eslint": "^8.31.1",
|
|
63
|
+
"uuid": "11.1.0"
|
|
74
64
|
},
|
|
75
65
|
"directories": {
|
|
76
66
|
"lib": "./lib/mongoose"
|
|
@@ -96,8 +86,6 @@
|
|
|
96
86
|
"lint-js": "eslint . --ext .js --ext .cjs",
|
|
97
87
|
"lint-ts": "eslint . --ext .ts",
|
|
98
88
|
"lint-md": "markdownlint-cli2 \"**/*.md\" \"#node_modules\" \"#benchmarks\"",
|
|
99
|
-
"build-browser": "(rm ./dist/* || true) && node ./scripts/build-browser.js",
|
|
100
|
-
"prepublishOnly": "npm run build-browser",
|
|
101
89
|
"release": "git pull && git push origin master --tags && npm publish",
|
|
102
90
|
"release-5x": "git pull origin 5.x && git push origin 5.x && git push origin 5.x --tags && npm publish --tag 5x",
|
|
103
91
|
"release-6x": "git pull origin 6.x && git push origin 6.x && git push origin 6.x --tags && npm publish --tag 6x",
|
|
@@ -107,7 +95,7 @@
|
|
|
107
95
|
"test": "mocha --exit ./test/*.test.js",
|
|
108
96
|
"test-deno": "deno run --allow-env --allow-read --allow-net --allow-run --allow-sys --allow-write ./test/deno.mjs",
|
|
109
97
|
"test-rs": "START_REPLICA_SET=1 mocha --timeout 30000 --exit ./test/*.test.js",
|
|
110
|
-
"test-tsd": "node ./test/types/check-types-filename && tsd",
|
|
98
|
+
"test-tsd": "node ./test/types/check-types-filename && tsd --full",
|
|
111
99
|
"setup-test-encryption": "node scripts/setup-encryption-tests.js",
|
|
112
100
|
"test-encryption": "mocha --exit ./test/encryption/*.test.js",
|
|
113
101
|
"tdd": "mocha ./test/*.test.js --inspect --watch --recursive --watch-files ./**/*.{js,ts}",
|
|
@@ -118,7 +106,7 @@
|
|
|
118
106
|
"main": "./index.js",
|
|
119
107
|
"types": "./types/index.d.ts",
|
|
120
108
|
"engines": {
|
|
121
|
-
"node": ">=
|
|
109
|
+
"node": ">=20.19.0"
|
|
122
110
|
},
|
|
123
111
|
"bugs": {
|
|
124
112
|
"url": "https://github.com/Automattic/mongoose/issues/new"
|
|
@@ -128,7 +116,6 @@
|
|
|
128
116
|
"url": "git://github.com/Automattic/mongoose.git"
|
|
129
117
|
},
|
|
130
118
|
"homepage": "https://mongoosejs.com",
|
|
131
|
-
"browser": "./dist/browser.umd.js",
|
|
132
119
|
"config": {
|
|
133
120
|
"mongodbMemoryServer": {
|
|
134
121
|
"disablePostinstall": true
|
|
@@ -148,7 +135,7 @@
|
|
|
148
135
|
"noImplicitAny": false,
|
|
149
136
|
"strictNullChecks": true,
|
|
150
137
|
"module": "commonjs",
|
|
151
|
-
"target": "
|
|
138
|
+
"target": "ES2022"
|
|
152
139
|
}
|
|
153
140
|
}
|
|
154
141
|
}
|
package/types/connection.d.ts
CHANGED
|
@@ -186,16 +186,25 @@ declare module 'mongoose' {
|
|
|
186
186
|
collection?: string,
|
|
187
187
|
options?: CompileModelOptions
|
|
188
188
|
): Model<
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
189
|
+
InferSchemaType<TSchema>,
|
|
190
|
+
ObtainSchemaGeneric<TSchema, 'TQueryHelpers'>,
|
|
191
|
+
ObtainSchemaGeneric<TSchema, 'TInstanceMethods'>,
|
|
192
|
+
ObtainSchemaGeneric<TSchema, 'TVirtuals'>,
|
|
193
|
+
// If first schema generic param is set, that means we have an explicit raw doc type,
|
|
194
|
+
// so user should also specify a hydrated doc type if the auto inferred one isn't correct.
|
|
195
|
+
IsItRecordAndNotAny<ObtainSchemaGeneric<TSchema, 'EnforcedDocType'>> extends true
|
|
196
|
+
? ObtainSchemaGeneric<TSchema, 'THydratedDocumentType'>
|
|
197
|
+
: HydratedDocument<
|
|
198
|
+
InferSchemaType<TSchema>,
|
|
199
|
+
ObtainSchemaGeneric<TSchema, 'TVirtuals'> & ObtainSchemaGeneric<TSchema, 'TInstanceMethods'>,
|
|
200
|
+
ObtainSchemaGeneric<TSchema, 'TQueryHelpers'>,
|
|
201
|
+
ObtainSchemaGeneric<TSchema, 'TVirtuals'>,
|
|
202
|
+
InferSchemaType<TSchema>,
|
|
203
|
+
ObtainSchemaGeneric<TSchema, 'TSchemaOptions'>
|
|
204
|
+
>,
|
|
205
|
+
TSchema,
|
|
206
|
+
ObtainSchemaGeneric<TSchema, 'TLeanResultType'>
|
|
207
|
+
> & ObtainSchemaGeneric<TSchema, 'TStaticMethods'>;
|
|
199
208
|
model<T, U, TQueryHelpers = {}>(
|
|
200
209
|
name: string,
|
|
201
210
|
schema?: Schema<T, any, any, TQueryHelpers, any, any, any>,
|
|
@@ -273,7 +282,7 @@ declare module 'mongoose' {
|
|
|
273
282
|
transaction<ReturnType = unknown>(fn: (session: mongodb.ClientSession) => Promise<ReturnType>, options?: mongodb.TransactionOptions): Promise<ReturnType>;
|
|
274
283
|
|
|
275
284
|
/** Switches to a different database using the same connection pool. */
|
|
276
|
-
useDb(name: string, options?: { useCache?: boolean
|
|
285
|
+
useDb(name: string, options?: { useCache?: boolean }): Connection;
|
|
277
286
|
|
|
278
287
|
/** The username specified in the URI */
|
|
279
288
|
readonly user: string;
|