mongoose 8.16.5 → 8.17.1
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/helpers/model/discriminator.js +2 -1
- package/lib/model.js +2 -13
- package/lib/mongoose.js +22 -0
- package/lib/query.js +23 -18
- package/lib/schema/array.js +8 -0
- package/lib/schema/bigint.js +8 -0
- package/lib/schema/boolean.js +8 -0
- package/lib/schema/buffer.js +8 -0
- package/lib/schema/date.js +8 -0
- package/lib/schema/decimal128.js +8 -0
- package/lib/schema/documentArray.js +13 -1
- package/lib/schema/double.js +8 -0
- package/lib/schema/int32.js +8 -0
- package/lib/schema/number.js +8 -0
- package/lib/schema/objectId.js +8 -0
- package/lib/schema/string.js +11 -3
- package/lib/schema/subdocument.js +27 -9
- package/lib/schema/uuid.js +8 -0
- package/lib/schemaType.js +6 -2
- package/package.json +6 -6
- package/types/aggregate.d.ts +1 -1
- package/types/collection.d.ts +2 -0
- package/types/connection.d.ts +2 -0
- package/types/document.d.ts +16 -16
- package/types/index.d.ts +20 -20
- package/types/models.d.ts +30 -9
- package/types/query.d.ts +4 -14
- package/types/schematypes.d.ts +24 -17
package/lib/model.js
CHANGED
|
@@ -1099,7 +1099,7 @@ Model.init = function init() {
|
|
|
1099
1099
|
return;
|
|
1100
1100
|
}
|
|
1101
1101
|
|
|
1102
|
-
return await this.
|
|
1102
|
+
return await this.createSearchIndexes();
|
|
1103
1103
|
};
|
|
1104
1104
|
const _createCollection = async() => {
|
|
1105
1105
|
let autoCreate = utils.getOption(
|
|
@@ -2092,9 +2092,7 @@ Model.find = function find(conditions, projection, options) {
|
|
|
2092
2092
|
};
|
|
2093
2093
|
|
|
2094
2094
|
/**
|
|
2095
|
-
* Finds a single document by its _id field. `findById(id)` is
|
|
2096
|
-
* equivalent to `findOne({ _id: id })`. If you want to query by a document's
|
|
2097
|
-
* `_id`, use `findById()` instead of `findOne()`.
|
|
2095
|
+
* Finds a single document by its _id field. `findById(id)` is equivalent to `findOne({ _id: id })`.
|
|
2098
2096
|
*
|
|
2099
2097
|
* The `id` is cast based on the Schema before sending the command.
|
|
2100
2098
|
*
|
|
@@ -2102,11 +2100,6 @@ Model.find = function find(conditions, projection, options) {
|
|
|
2102
2100
|
*
|
|
2103
2101
|
* - `findOne()`
|
|
2104
2102
|
*
|
|
2105
|
-
* \* Except for how it treats `undefined`. If you use `findOne()`, you'll see
|
|
2106
|
-
* that `findOne(undefined)` and `findOne({ _id: undefined })` are equivalent
|
|
2107
|
-
* to `findOne({})` and return arbitrary documents. However, mongoose
|
|
2108
|
-
* translates `findById(undefined)` into `findOne({ _id: null })`.
|
|
2109
|
-
*
|
|
2110
2103
|
* #### Example:
|
|
2111
2104
|
*
|
|
2112
2105
|
* // Find the adventure with the given `id`, or `null` if not found
|
|
@@ -2131,10 +2124,6 @@ Model.findById = function findById(id, projection, options) {
|
|
|
2131
2124
|
throw new MongooseError('Model.findById() no longer accepts a callback');
|
|
2132
2125
|
}
|
|
2133
2126
|
|
|
2134
|
-
if (typeof id === 'undefined') {
|
|
2135
|
-
id = null;
|
|
2136
|
-
}
|
|
2137
|
-
|
|
2138
2127
|
return this.findOne({ _id: id }, projection, options);
|
|
2139
2128
|
};
|
|
2140
2129
|
|
package/lib/mongoose.js
CHANGED
|
@@ -855,6 +855,17 @@ Mongoose.prototype.nextConnectionId;
|
|
|
855
855
|
|
|
856
856
|
Mongoose.prototype.Aggregate = Aggregate;
|
|
857
857
|
|
|
858
|
+
/**
|
|
859
|
+
* The Base Mongoose Collection class. `mongoose.Collection` extends from this class.
|
|
860
|
+
*
|
|
861
|
+
* @memberOf Mongoose
|
|
862
|
+
* @instance
|
|
863
|
+
* @method Collection
|
|
864
|
+
* @api public
|
|
865
|
+
*/
|
|
866
|
+
|
|
867
|
+
Mongoose.prototype.BaseCollection = require('./collection');
|
|
868
|
+
|
|
858
869
|
/**
|
|
859
870
|
* The Mongoose Collection constructor
|
|
860
871
|
*
|
|
@@ -895,6 +906,17 @@ Object.defineProperty(Mongoose.prototype, 'Connection', {
|
|
|
895
906
|
}
|
|
896
907
|
});
|
|
897
908
|
|
|
909
|
+
/**
|
|
910
|
+
* The Base Mongoose Connection class. `mongoose.Connection` extends from this class.
|
|
911
|
+
*
|
|
912
|
+
* @memberOf Mongoose
|
|
913
|
+
* @instance
|
|
914
|
+
* @method Connection
|
|
915
|
+
* @api public
|
|
916
|
+
*/
|
|
917
|
+
|
|
918
|
+
Mongoose.prototype.BaseConnection = require('./connection');
|
|
919
|
+
|
|
898
920
|
/**
|
|
899
921
|
* The Mongoose version
|
|
900
922
|
*
|
package/lib/query.js
CHANGED
|
@@ -2133,6 +2133,29 @@ Query.prototype._optionsForExec = function(model) {
|
|
|
2133
2133
|
}
|
|
2134
2134
|
}
|
|
2135
2135
|
|
|
2136
|
+
if (this._mongooseOptions.populate) {
|
|
2137
|
+
if (options.readPreference) {
|
|
2138
|
+
for (const pop of Object.values(this._mongooseOptions.populate)) {
|
|
2139
|
+
if (pop.options?.readPreference === undefined) {
|
|
2140
|
+
if (!pop.options) {
|
|
2141
|
+
pop.options = {};
|
|
2142
|
+
}
|
|
2143
|
+
pop.options.readPreference = options.readPreference;
|
|
2144
|
+
}
|
|
2145
|
+
}
|
|
2146
|
+
}
|
|
2147
|
+
if (options.readConcern) {
|
|
2148
|
+
for (const pop of Object.values(this._mongooseOptions.populate)) {
|
|
2149
|
+
if (pop.options?.readConcern === undefined) {
|
|
2150
|
+
if (!pop.options) {
|
|
2151
|
+
pop.options = {};
|
|
2152
|
+
}
|
|
2153
|
+
pop.options.readConcern = options.readConcern;
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
}
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2136
2159
|
return options;
|
|
2137
2160
|
};
|
|
2138
2161
|
|
|
@@ -4918,24 +4941,6 @@ Query.prototype.populate = function() {
|
|
|
4918
4941
|
|
|
4919
4942
|
const res = utils.populate.apply(null, args);
|
|
4920
4943
|
|
|
4921
|
-
// Propagate readConcern and readPreference and lean from parent query,
|
|
4922
|
-
// unless one already specified
|
|
4923
|
-
if (this.options != null) {
|
|
4924
|
-
const readConcern = this.options.readConcern;
|
|
4925
|
-
const readPref = this.options.readPreference;
|
|
4926
|
-
|
|
4927
|
-
for (const populateOptions of res) {
|
|
4928
|
-
if (readConcern != null && (populateOptions && populateOptions.options && populateOptions.options.readConcern) == null) {
|
|
4929
|
-
populateOptions.options = populateOptions.options || {};
|
|
4930
|
-
populateOptions.options.readConcern = readConcern;
|
|
4931
|
-
}
|
|
4932
|
-
if (readPref != null && (populateOptions && populateOptions.options && populateOptions.options.readPreference) == null) {
|
|
4933
|
-
populateOptions.options = populateOptions.options || {};
|
|
4934
|
-
populateOptions.options.readPreference = readPref;
|
|
4935
|
-
}
|
|
4936
|
-
}
|
|
4937
|
-
}
|
|
4938
|
-
|
|
4939
4944
|
const opts = this._mongooseOptions;
|
|
4940
4945
|
|
|
4941
4946
|
if (opts.lean != null) {
|
package/lib/schema/array.js
CHANGED
|
@@ -649,6 +649,14 @@ function cast$elemMatch(val, context) {
|
|
|
649
649
|
return val;
|
|
650
650
|
}
|
|
651
651
|
|
|
652
|
+
/**
|
|
653
|
+
* Contains the handlers for different query operators for this schema type.
|
|
654
|
+
* For example, `$conditionalHandlers.$all` is the function Mongoose calls to cast `$all` filter operators.
|
|
655
|
+
*
|
|
656
|
+
* @property $conditionalHandlers
|
|
657
|
+
* @api public
|
|
658
|
+
*/
|
|
659
|
+
|
|
652
660
|
const handle = SchemaArray.prototype.$conditionalHandlers = {};
|
|
653
661
|
|
|
654
662
|
handle.$all = cast$all;
|
package/lib/schema/bigint.js
CHANGED
|
@@ -185,6 +185,14 @@ const $conditionalHandlers = {
|
|
|
185
185
|
$lte: handleSingle
|
|
186
186
|
};
|
|
187
187
|
|
|
188
|
+
/**
|
|
189
|
+
* Contains the handlers for different query operators for this schema type.
|
|
190
|
+
* For example, `$conditionalHandlers.$in` is the function Mongoose calls to cast `$in` filter operators.
|
|
191
|
+
*
|
|
192
|
+
* @property $conditionalHandlers
|
|
193
|
+
* @api public
|
|
194
|
+
*/
|
|
195
|
+
|
|
188
196
|
Object.defineProperty(SchemaBigInt.prototype, '$conditionalHandlers', {
|
|
189
197
|
enumerable: false,
|
|
190
198
|
value: $conditionalHandlers
|
package/lib/schema/boolean.js
CHANGED
|
@@ -237,6 +237,14 @@ SchemaBoolean.prototype.cast = function(value) {
|
|
|
237
237
|
|
|
238
238
|
const $conditionalHandlers = { ...SchemaType.prototype.$conditionalHandlers };
|
|
239
239
|
|
|
240
|
+
/**
|
|
241
|
+
* Contains the handlers for different query operators for this schema type.
|
|
242
|
+
* For example, `$conditionalHandlers.$in` is the function Mongoose calls to cast `$in` filter operators.
|
|
243
|
+
*
|
|
244
|
+
* @property $conditionalHandlers
|
|
245
|
+
* @api public
|
|
246
|
+
*/
|
|
247
|
+
|
|
240
248
|
Object.defineProperty(SchemaBoolean.prototype, '$conditionalHandlers', {
|
|
241
249
|
enumerable: false,
|
|
242
250
|
value: $conditionalHandlers
|
package/lib/schema/buffer.js
CHANGED
|
@@ -271,6 +271,14 @@ const $conditionalHandlers = {
|
|
|
271
271
|
$lte: handleSingle
|
|
272
272
|
};
|
|
273
273
|
|
|
274
|
+
/**
|
|
275
|
+
* Contains the handlers for different query operators for this schema type.
|
|
276
|
+
* For example, `$conditionalHandlers.$exists` is the function Mongoose calls to cast `$exists` filter operators.
|
|
277
|
+
*
|
|
278
|
+
* @property $conditionalHandlers
|
|
279
|
+
* @api public
|
|
280
|
+
*/
|
|
281
|
+
|
|
274
282
|
Object.defineProperty(SchemaBuffer.prototype, '$conditionalHandlers', {
|
|
275
283
|
enumerable: false,
|
|
276
284
|
value: $conditionalHandlers
|
package/lib/schema/date.js
CHANGED
|
@@ -397,6 +397,14 @@ const $conditionalHandlers = {
|
|
|
397
397
|
$lte: handleSingle
|
|
398
398
|
};
|
|
399
399
|
|
|
400
|
+
/**
|
|
401
|
+
* Contains the handlers for different query operators for this schema type.
|
|
402
|
+
* For example, `$conditionalHandlers.$gte` is the function Mongoose calls to cast `$gte` filter operators.
|
|
403
|
+
*
|
|
404
|
+
* @property $conditionalHandlers
|
|
405
|
+
* @api public
|
|
406
|
+
*/
|
|
407
|
+
|
|
400
408
|
Object.defineProperty(SchemaDate.prototype, '$conditionalHandlers', {
|
|
401
409
|
enumerable: false,
|
|
402
410
|
value: $conditionalHandlers
|
package/lib/schema/decimal128.js
CHANGED
|
@@ -222,6 +222,14 @@ const $conditionalHandlers = {
|
|
|
222
222
|
$lte: handleSingle
|
|
223
223
|
};
|
|
224
224
|
|
|
225
|
+
/**
|
|
226
|
+
* Contains the handlers for different query operators for this schema type.
|
|
227
|
+
* For example, `$conditionalHandlers.$lte` is the function Mongoose calls to cast `$lte` filter operators.
|
|
228
|
+
*
|
|
229
|
+
* @property $conditionalHandlers
|
|
230
|
+
* @api public
|
|
231
|
+
*/
|
|
232
|
+
|
|
225
233
|
Object.defineProperty(SchemaDecimal128.prototype, '$conditionalHandlers', {
|
|
226
234
|
enumerable: false,
|
|
227
235
|
value: $conditionalHandlers
|
|
@@ -116,7 +116,19 @@ SchemaDocumentArray.options = { castNonArrays: true };
|
|
|
116
116
|
SchemaDocumentArray.prototype = Object.create(SchemaArray.prototype);
|
|
117
117
|
SchemaDocumentArray.prototype.constructor = SchemaDocumentArray;
|
|
118
118
|
SchemaDocumentArray.prototype.OptionsConstructor = SchemaDocumentArrayOptions;
|
|
119
|
-
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Contains the handlers for different query operators for this schema type.
|
|
122
|
+
* For example, `$conditionalHandlers.$size` is the function Mongoose calls to cast `$size` filter operators.
|
|
123
|
+
*
|
|
124
|
+
* @property $conditionalHandlers
|
|
125
|
+
* @api public
|
|
126
|
+
*/
|
|
127
|
+
|
|
128
|
+
Object.defineProperty(SchemaDocumentArray.prototype, '$conditionalHandlers', {
|
|
129
|
+
enumerable: false,
|
|
130
|
+
value: { ...SchemaArray.prototype.$conditionalHandlers }
|
|
131
|
+
});
|
|
120
132
|
|
|
121
133
|
/*!
|
|
122
134
|
* ignore
|
package/lib/schema/double.js
CHANGED
|
@@ -205,6 +205,14 @@ const $conditionalHandlers = {
|
|
|
205
205
|
$lte: handleSingle
|
|
206
206
|
};
|
|
207
207
|
|
|
208
|
+
/**
|
|
209
|
+
* Contains the handlers for different query operators for this schema type.
|
|
210
|
+
* For example, `$conditionalHandlers.$lt` is the function Mongoose calls to cast `$lt` filter operators.
|
|
211
|
+
*
|
|
212
|
+
* @property $conditionalHandlers
|
|
213
|
+
* @api public
|
|
214
|
+
*/
|
|
215
|
+
|
|
208
216
|
Object.defineProperty(SchemaDouble.prototype, '$conditionalHandlers', {
|
|
209
217
|
enumerable: false,
|
|
210
218
|
value: $conditionalHandlers
|
package/lib/schema/int32.js
CHANGED
|
@@ -209,6 +209,14 @@ const $conditionalHandlers = {
|
|
|
209
209
|
$bitsAnySet: handleBitwiseOperator
|
|
210
210
|
};
|
|
211
211
|
|
|
212
|
+
/**
|
|
213
|
+
* Contains the handlers for different query operators for this schema type.
|
|
214
|
+
* For example, `$conditionalHandlers.$gt` is the function Mongoose calls to cast `$gt` filter operators.
|
|
215
|
+
*
|
|
216
|
+
* @property $conditionalHandlers
|
|
217
|
+
* @api public
|
|
218
|
+
*/
|
|
219
|
+
|
|
212
220
|
Object.defineProperty(SchemaInt32.prototype, '$conditionalHandlers', {
|
|
213
221
|
enumerable: false,
|
|
214
222
|
value: $conditionalHandlers
|
package/lib/schema/number.js
CHANGED
|
@@ -413,6 +413,14 @@ const $conditionalHandlers = {
|
|
|
413
413
|
$mod: handleArray
|
|
414
414
|
};
|
|
415
415
|
|
|
416
|
+
/**
|
|
417
|
+
* Contains the handlers for different query operators for this schema type.
|
|
418
|
+
* For example, `$conditionalHandlers.$gte` is the function Mongoose calls to cast `$gte` filter operators.
|
|
419
|
+
*
|
|
420
|
+
* @property $conditionalHandlers
|
|
421
|
+
* @api public
|
|
422
|
+
*/
|
|
423
|
+
|
|
416
424
|
Object.defineProperty(SchemaNumber.prototype, '$conditionalHandlers', {
|
|
417
425
|
enumerable: false,
|
|
418
426
|
value: $conditionalHandlers
|
package/lib/schema/objectId.js
CHANGED
|
@@ -268,6 +268,14 @@ const $conditionalHandlers = {
|
|
|
268
268
|
$lte: handleSingle
|
|
269
269
|
};
|
|
270
270
|
|
|
271
|
+
/**
|
|
272
|
+
* Contains the handlers for different query operators for this schema type.
|
|
273
|
+
* For example, `$conditionalHandlers.$in` is the function Mongoose calls to cast `$in` filter operators.
|
|
274
|
+
*
|
|
275
|
+
* @property $conditionalHandlers
|
|
276
|
+
* @api public
|
|
277
|
+
*/
|
|
278
|
+
|
|
271
279
|
Object.defineProperty(SchemaObjectId.prototype, '$conditionalHandlers', {
|
|
272
280
|
enumerable: false,
|
|
273
281
|
value: $conditionalHandlers
|
package/lib/schema/string.js
CHANGED
|
@@ -381,7 +381,7 @@ SchemaString.prototype.trim = function(shouldTrim) {
|
|
|
381
381
|
*
|
|
382
382
|
* #### Example:
|
|
383
383
|
*
|
|
384
|
-
* const schema = new Schema({ postalCode: { type: String,
|
|
384
|
+
* const schema = new Schema({ postalCode: { type: String, minLength: 5 })
|
|
385
385
|
* const Address = db.model('Address', schema)
|
|
386
386
|
* const address = new Address({ postalCode: '9512' })
|
|
387
387
|
* address.save(function (err) {
|
|
@@ -392,8 +392,8 @@ SchemaString.prototype.trim = function(shouldTrim) {
|
|
|
392
392
|
*
|
|
393
393
|
* // custom error messages
|
|
394
394
|
* // We can also use the special {MINLENGTH} token which will be replaced with the minimum allowed length
|
|
395
|
-
* const
|
|
396
|
-
* const schema = new Schema({ postalCode: { type: String,
|
|
395
|
+
* const minLength = [5, 'The value of path `{PATH}` (`{VALUE}`) is shorter than the minimum allowed length ({MINLENGTH}).'];
|
|
396
|
+
* const schema = new Schema({ postalCode: { type: String, minLength: minLength })
|
|
397
397
|
* const Address = mongoose.model('Address', schema);
|
|
398
398
|
* const address = new Address({ postalCode: '9512' });
|
|
399
399
|
* address.validate(function (err) {
|
|
@@ -660,6 +660,14 @@ const $conditionalHandlers = {
|
|
|
660
660
|
$not: handleSingle
|
|
661
661
|
};
|
|
662
662
|
|
|
663
|
+
/**
|
|
664
|
+
* Contains the handlers for different query operators for this schema type.
|
|
665
|
+
* For example, `$conditionalHandlers.$exists` is the function Mongoose calls to cast `$exists` filter operators.
|
|
666
|
+
*
|
|
667
|
+
* @property $conditionalHandlers
|
|
668
|
+
* @api public
|
|
669
|
+
*/
|
|
670
|
+
|
|
663
671
|
Object.defineProperty(SchemaString.prototype, '$conditionalHandlers', {
|
|
664
672
|
enumerable: false,
|
|
665
673
|
value: $conditionalHandlers
|
|
@@ -117,6 +117,11 @@ function _createConstructor(schema, baseClass, options) {
|
|
|
117
117
|
return _embedded;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
+
/*!
|
|
121
|
+
* ignore
|
|
122
|
+
*/
|
|
123
|
+
const $conditionalHandlers = { ...SchemaType.prototype.$conditionalHandlers };
|
|
124
|
+
|
|
120
125
|
/**
|
|
121
126
|
* Special case for when users use a common location schema to represent
|
|
122
127
|
* locations for use with $geoWithin.
|
|
@@ -126,7 +131,7 @@ function _createConstructor(schema, baseClass, options) {
|
|
|
126
131
|
* @api private
|
|
127
132
|
*/
|
|
128
133
|
|
|
129
|
-
|
|
134
|
+
$conditionalHandlers.$geoWithin = function handle$geoWithin(val, context) {
|
|
130
135
|
return { $geometry: this.castForQuery(null, val.$geometry, context) };
|
|
131
136
|
};
|
|
132
137
|
|
|
@@ -134,19 +139,32 @@ SchemaSubdocument.prototype.$conditionalHandlers.$geoWithin = function handle$ge
|
|
|
134
139
|
* ignore
|
|
135
140
|
*/
|
|
136
141
|
|
|
137
|
-
|
|
138
|
-
|
|
142
|
+
$conditionalHandlers.$near =
|
|
143
|
+
$conditionalHandlers.$nearSphere = geospatial.cast$near;
|
|
139
144
|
|
|
140
|
-
|
|
141
|
-
|
|
145
|
+
$conditionalHandlers.$within =
|
|
146
|
+
$conditionalHandlers.$geoWithin = geospatial.cast$within;
|
|
142
147
|
|
|
143
|
-
|
|
148
|
+
$conditionalHandlers.$geoIntersects =
|
|
144
149
|
geospatial.cast$geoIntersects;
|
|
145
150
|
|
|
146
|
-
|
|
147
|
-
|
|
151
|
+
$conditionalHandlers.$minDistance = castToNumber;
|
|
152
|
+
$conditionalHandlers.$maxDistance = castToNumber;
|
|
153
|
+
|
|
154
|
+
$conditionalHandlers.$exists = $exists;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Contains the handlers for different query operators for this schema type.
|
|
158
|
+
* For example, `$conditionalHandlers.$exists` is the function Mongoose calls to cast `$exists` filter operators.
|
|
159
|
+
*
|
|
160
|
+
* @property $conditionalHandlers
|
|
161
|
+
* @api public
|
|
162
|
+
*/
|
|
148
163
|
|
|
149
|
-
SchemaSubdocument.prototype
|
|
164
|
+
Object.defineProperty(SchemaSubdocument.prototype, '$conditionalHandlers', {
|
|
165
|
+
enumerable: false,
|
|
166
|
+
value: $conditionalHandlers
|
|
167
|
+
});
|
|
150
168
|
|
|
151
169
|
/**
|
|
152
170
|
* Casts contents
|
package/lib/schema/uuid.js
CHANGED
|
@@ -258,6 +258,14 @@ const $conditionalHandlers = {
|
|
|
258
258
|
$nin: handleArray
|
|
259
259
|
};
|
|
260
260
|
|
|
261
|
+
/**
|
|
262
|
+
* Contains the handlers for different query operators for this schema type.
|
|
263
|
+
* For example, `$conditionalHandlers.$exists` is the function Mongoose calls to cast `$exists` filter operators.
|
|
264
|
+
*
|
|
265
|
+
* @property $conditionalHandlers
|
|
266
|
+
* @api public
|
|
267
|
+
*/
|
|
268
|
+
|
|
261
269
|
Object.defineProperty(SchemaUUID.prototype, '$conditionalHandlers', {
|
|
262
270
|
enumerable: false,
|
|
263
271
|
value: $conditionalHandlers
|
package/lib/schemaType.js
CHANGED
|
@@ -1638,8 +1638,12 @@ function handle$in(val, context) {
|
|
|
1638
1638
|
});
|
|
1639
1639
|
}
|
|
1640
1640
|
|
|
1641
|
-
|
|
1642
|
-
*
|
|
1641
|
+
/**
|
|
1642
|
+
* Contains the handlers for different query operators for this schema type.
|
|
1643
|
+
* For example, `$conditionalHandlers.$exists` is the function Mongoose calls to cast `$exists` filter operators.
|
|
1644
|
+
*
|
|
1645
|
+
* @property $conditionalHandlers
|
|
1646
|
+
* @api public
|
|
1643
1647
|
*/
|
|
1644
1648
|
|
|
1645
1649
|
SchemaType.prototype.$conditionalHandlers = {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mongoose",
|
|
3
3
|
"description": "Mongoose MongoDB ODM",
|
|
4
|
-
"version": "8.
|
|
4
|
+
"version": "8.17.1",
|
|
5
5
|
"author": "Guillermo Rauch <guillermo@learnboost.com>",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"mongodb",
|
|
@@ -22,15 +22,15 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"bson": "^6.10.4",
|
|
24
24
|
"kareem": "2.6.3",
|
|
25
|
-
"mongodb": "~6.
|
|
25
|
+
"mongodb": "~6.18.0",
|
|
26
26
|
"mpath": "0.9.0",
|
|
27
27
|
"mquery": "5.0.0",
|
|
28
28
|
"ms": "2.1.3",
|
|
29
29
|
"sift": "17.1.3"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@babel/core": "7.
|
|
33
|
-
"@babel/preset-env": "7.
|
|
32
|
+
"@babel/core": "7.28.0",
|
|
33
|
+
"@babel/preset-env": "7.28.0",
|
|
34
34
|
"@mongodb-js/mongodb-downloader": "^0.4.2",
|
|
35
35
|
"@typescript-eslint/eslint-plugin": "^8.19.1",
|
|
36
36
|
"@typescript-eslint/parser": "^8.19.1",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"babel-loader": "8.2.5",
|
|
43
43
|
"broken-link-checker": "^0.7.8",
|
|
44
44
|
"buffer": "^5.6.0",
|
|
45
|
-
"cheerio": "1.1.
|
|
45
|
+
"cheerio": "1.1.2",
|
|
46
46
|
"crypto-browserify": "3.12.1",
|
|
47
47
|
"dox": "1.0.0",
|
|
48
48
|
"eslint": "8.57.1",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"tsd": "0.32.0",
|
|
70
70
|
"typescript": "5.8.3",
|
|
71
71
|
"uuid": "11.1.0",
|
|
72
|
-
"webpack": "5.
|
|
72
|
+
"webpack": "5.101.0"
|
|
73
73
|
},
|
|
74
74
|
"directories": {
|
|
75
75
|
"lib": "./lib/mongoose"
|
package/types/aggregate.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ declare module 'mongoose' {
|
|
|
4
4
|
/** Extract generic type from Aggregate class */
|
|
5
5
|
type AggregateExtract<P> = P extends Aggregate<infer T> ? T : never;
|
|
6
6
|
|
|
7
|
-
interface AggregateOptions extends Omit<mongodb.AggregateOptions, 'session'>, SessionOption {
|
|
7
|
+
interface AggregateOptions extends Omit<mongodb.AggregateOptions & mongodb.Abortable, 'session'>, SessionOption {
|
|
8
8
|
[key: string]: any;
|
|
9
9
|
}
|
|
10
10
|
|
package/types/collection.d.ts
CHANGED
package/types/connection.d.ts
CHANGED
|
@@ -71,6 +71,8 @@ declare module 'mongoose' {
|
|
|
71
71
|
};
|
|
72
72
|
}[keyof SchemaMap];
|
|
73
73
|
|
|
74
|
+
export type BaseConnection = Connection;
|
|
75
|
+
|
|
74
76
|
class Connection extends events.EventEmitter implements SessionStarter {
|
|
75
77
|
/** Runs a [db-level aggregate()](https://www.mongodb.com/docs/manual/reference/method/db.aggregate/) on this connection's underlying `db` */
|
|
76
78
|
aggregate<ResultType = unknown>(pipeline?: PipelineStage[] | null, options?: AggregateOptions): Aggregate<Array<ResultType>>;
|
package/types/document.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ declare module 'mongoose' {
|
|
|
18
18
|
* * TQueryHelpers - Object with any helpers that should be mixed into the Query type
|
|
19
19
|
* * DocType - the type of the actual Document created
|
|
20
20
|
*/
|
|
21
|
-
class Document<T = unknown, TQueryHelpers = any, DocType = any, TVirtuals = Record<string, any
|
|
21
|
+
class Document<T = unknown, TQueryHelpers = any, DocType = any, TVirtuals = Record<string, any>, TSchemaOptions = {}> {
|
|
22
22
|
constructor(doc?: any);
|
|
23
23
|
|
|
24
24
|
/** This documents _id. */
|
|
@@ -256,23 +256,23 @@ declare module 'mongoose' {
|
|
|
256
256
|
set(value: string | Record<string, any>): this;
|
|
257
257
|
|
|
258
258
|
/** The return value of this method is used in calls to JSON.stringify(doc). */
|
|
259
|
-
toJSON(options: ToObjectOptions & { virtuals: true }): Default__v<Require_id<DocType & TVirtuals
|
|
260
|
-
toJSON(options?: ToObjectOptions & { flattenMaps?: true, flattenObjectIds?: false }): FlattenMaps<Default__v<Require_id<DocType
|
|
261
|
-
toJSON(options: ToObjectOptions & { flattenObjectIds: false }): FlattenMaps<Default__v<Require_id<DocType
|
|
262
|
-
toJSON(options: ToObjectOptions & { flattenObjectIds: true }): ObjectIdToString<FlattenMaps<Default__v<Require_id<DocType
|
|
263
|
-
toJSON(options: ToObjectOptions & { flattenMaps: false }): Default__v<Require_id<DocType
|
|
264
|
-
toJSON(options: ToObjectOptions & { flattenMaps: false; flattenObjectIds: true }): ObjectIdToString<Default__v<Require_id<DocType
|
|
265
|
-
|
|
266
|
-
toJSON<T = Default__v<Require_id<DocType
|
|
267
|
-
toJSON<T = Default__v<Require_id<DocType
|
|
268
|
-
toJSON<T = Default__v<Require_id<DocType
|
|
269
|
-
toJSON<T = Default__v<Require_id<DocType
|
|
270
|
-
toJSON<T = Default__v<Require_id<DocType
|
|
259
|
+
toJSON(options: ToObjectOptions & { virtuals: true }): Default__v<Require_id<DocType & TVirtuals>, TSchemaOptions>;
|
|
260
|
+
toJSON(options?: ToObjectOptions & { flattenMaps?: true, flattenObjectIds?: false }): FlattenMaps<Default__v<Require_id<DocType>, TSchemaOptions>>;
|
|
261
|
+
toJSON(options: ToObjectOptions & { flattenObjectIds: false }): FlattenMaps<Default__v<Require_id<DocType>, TSchemaOptions>>;
|
|
262
|
+
toJSON(options: ToObjectOptions & { flattenObjectIds: true }): ObjectIdToString<FlattenMaps<Default__v<Require_id<DocType>, TSchemaOptions>>>;
|
|
263
|
+
toJSON(options: ToObjectOptions & { flattenMaps: false }): Default__v<Require_id<DocType>, TSchemaOptions>;
|
|
264
|
+
toJSON(options: ToObjectOptions & { flattenMaps: false; flattenObjectIds: true }): ObjectIdToString<Default__v<Require_id<DocType>, TSchemaOptions>>;
|
|
265
|
+
|
|
266
|
+
toJSON<T = Default__v<Require_id<DocType>, TSchemaOptions>>(options?: ToObjectOptions & { flattenMaps?: true, flattenObjectIds?: false }): FlattenMaps<T>;
|
|
267
|
+
toJSON<T = Default__v<Require_id<DocType>, TSchemaOptions>>(options: ToObjectOptions & { flattenObjectIds: false }): FlattenMaps<T>;
|
|
268
|
+
toJSON<T = Default__v<Require_id<DocType>, TSchemaOptions>>(options: ToObjectOptions & { flattenObjectIds: true }): ObjectIdToString<FlattenMaps<T>>;
|
|
269
|
+
toJSON<T = Default__v<Require_id<DocType>, TSchemaOptions>>(options: ToObjectOptions & { flattenMaps: false }): T;
|
|
270
|
+
toJSON<T = Default__v<Require_id<DocType>, TSchemaOptions>>(options: ToObjectOptions & { flattenMaps: false, flattenObjectIds: true }): ObjectIdToString<T>;
|
|
271
271
|
|
|
272
272
|
/** Converts this document into a plain-old JavaScript object ([POJO](https://masteringjs.io/tutorials/fundamentals/pojo)). */
|
|
273
|
-
toObject(options: ToObjectOptions & { virtuals: true }): Default__v<Require_id<DocType & TVirtuals
|
|
274
|
-
toObject(options?: ToObjectOptions): Default__v<Require_id<DocType
|
|
275
|
-
toObject<T>(options?: ToObjectOptions): Default__v<Require_id<T
|
|
273
|
+
toObject(options: ToObjectOptions & { virtuals: true }): Default__v<Require_id<DocType & TVirtuals>, TSchemaOptions>;
|
|
274
|
+
toObject(options?: ToObjectOptions): Default__v<Require_id<DocType>, TSchemaOptions>;
|
|
275
|
+
toObject<T>(options?: ToObjectOptions): Default__v<Require_id<T>, TSchemaOptions>;
|
|
276
276
|
|
|
277
277
|
/** Clears the modified state on the specified path. */
|
|
278
278
|
unmarkModified<T extends keyof DocType>(path: T): void;
|