mongoose 9.3.2 → 9.3.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/lib/aggregate.js +1 -1
- package/lib/connection.js +1 -1
- package/lib/helpers/isBsonType.js +1 -1
- package/lib/mongoose.js +4 -4
- package/lib/query.js +1 -1
- package/lib/schema.js +3 -3
- package/lib/schemaType.js +9 -9
- package/package.json +1 -1
- package/types/utility.d.ts +1 -1
package/lib/aggregate.js
CHANGED
|
@@ -159,7 +159,7 @@ Aggregate.prototype.model = function(model) {
|
|
|
159
159
|
* const pipeline = [{ $match: { daw: 'Logic Audio X' }} ];
|
|
160
160
|
* aggregate.append(pipeline);
|
|
161
161
|
*
|
|
162
|
-
* @param {...object|object[]} ops operator(s) to append. Can either be a spread of objects or a single parameter of
|
|
162
|
+
* @param {...object|object[]} ops operator(s) to append. Can either be a spread of objects or a single parameter of an object array.
|
|
163
163
|
* @return {Aggregate}
|
|
164
164
|
* @api public
|
|
165
165
|
*/
|
package/lib/connection.js
CHANGED
|
@@ -177,7 +177,7 @@ Connection.prototype.get = function getOption(key) {
|
|
|
177
177
|
* Supported options include:
|
|
178
178
|
*
|
|
179
179
|
* - `maxTimeMS`: Set [`maxTimeMS`](https://mongoosejs.com/docs/api/query.html#Query.prototype.maxTimeMS()) for all queries on this connection.
|
|
180
|
-
* - 'debug': If `true`, prints the operations mongoose sends to MongoDB to the console. If a writable stream is passed, it will log to that stream, without colorization. If a callback function is passed, it will receive the collection name, the method name, then all
|
|
180
|
+
* - 'debug': If `true`, prints the operations mongoose sends to MongoDB to the console. If a writable stream is passed, it will log to that stream, without colorization. If a callback function is passed, it will receive the collection name, the method name, then all arguments passed to the method. For example, if you wanted to replicate the default logging, you could output from the callback `Mongoose: ${collectionName}.${methodName}(${methodArgs.join(', ')})`.
|
|
181
181
|
*
|
|
182
182
|
* #### Example:
|
|
183
183
|
*
|
package/lib/mongoose.js
CHANGED
|
@@ -206,8 +206,8 @@ Mongoose.prototype.setDriver = function setDriver(driver) {
|
|
|
206
206
|
/**
|
|
207
207
|
* Sets mongoose options
|
|
208
208
|
*
|
|
209
|
-
* `key` can be used
|
|
210
|
-
* If
|
|
209
|
+
* `key` can be used as an object to set multiple options at once.
|
|
210
|
+
* If an error gets thrown for one option, other options will still be evaluated.
|
|
211
211
|
*
|
|
212
212
|
* #### Example:
|
|
213
213
|
*
|
|
@@ -247,8 +247,8 @@ Mongoose.prototype.setDriver = function setDriver(driver) {
|
|
|
247
247
|
* - `translateAliases`: `false` by default. If `true`, Mongoose will automatically translate aliases to their original paths before sending the query to MongoDB.
|
|
248
248
|
* - `updatePipeline`: `false` by default. If `true`, allows passing update pipelines (arrays) to update operations by default without explicitly setting `updatePipeline: true` in each query.
|
|
249
249
|
*
|
|
250
|
-
* @param {string|object} key The name of the option or
|
|
251
|
-
* @param {string|Function|boolean} value The value of the option, unused if "key" is
|
|
250
|
+
* @param {string|object} key The name of the option or an object of multiple key-value pairs
|
|
251
|
+
* @param {string|Function|boolean} value The value of the option, unused if "key" is an object
|
|
252
252
|
* @returns {Mongoose} The used Mongoose instance
|
|
253
253
|
* @api public
|
|
254
254
|
*/
|
package/lib/query.js
CHANGED
|
@@ -5582,7 +5582,7 @@ Query.prototype[Symbol.asyncIterator] = function queryAsyncIterator() {
|
|
|
5582
5582
|
* @see $box https://www.mongodb.com/docs/manual/reference/operator/box/
|
|
5583
5583
|
* @see within() Query#within https://mongoosejs.com/docs/api/query.html#Query.prototype.within()
|
|
5584
5584
|
* @see MongoDB Geospatial Indexing https://www.mongodb.com/docs/manual/core/geospatial-indexes/
|
|
5585
|
-
* @param {object|Array<number>} val1 Lower Left Coordinates OR
|
|
5585
|
+
* @param {object|Array<number>} val1 Lower Left Coordinates OR an object of lower-left(ll) and upper-right(ur) Coordinates
|
|
5586
5586
|
* @param {Array<number>} [val2] Upper Right Coordinates
|
|
5587
5587
|
* @return {Query} this
|
|
5588
5588
|
* @api public
|
package/lib/schema.js
CHANGED
|
@@ -2253,7 +2253,7 @@ Schema.prototype.plugin = function(fn, opts) {
|
|
|
2253
2253
|
*
|
|
2254
2254
|
* NOTE: `Schema.method()` adds instance methods to the `Schema.methods` object. You can also add instance methods directly to the `Schema.methods` object as seen in the [guide](https://mongoosejs.com/docs/guide.html#methods)
|
|
2255
2255
|
*
|
|
2256
|
-
* @param {string|object} name The Method Name for a single function, or
|
|
2256
|
+
* @param {string|object} name The Method Name for a single function, or an Object of "string-function" pairs.
|
|
2257
2257
|
* @param {Function} [fn] The Function in a single-function definition.
|
|
2258
2258
|
* @api public
|
|
2259
2259
|
*/
|
|
@@ -2298,7 +2298,7 @@ Schema.prototype.method = function(name, fn, options) {
|
|
|
2298
2298
|
*
|
|
2299
2299
|
* If a hash of name/fn pairs is passed as the only argument, each name/fn pair will be added as statics.
|
|
2300
2300
|
*
|
|
2301
|
-
* @param {string|object} name The Method Name for a single function, or
|
|
2301
|
+
* @param {string|object} name The Method Name for a single function, or an Object of "string-function" pairs.
|
|
2302
2302
|
* @param {Function} [fn] The Function in a single-function definition.
|
|
2303
2303
|
* @api public
|
|
2304
2304
|
* @see Statics https://mongoosejs.com/docs/guide.html#statics
|
|
@@ -3119,7 +3119,7 @@ Schema.prototype.toJSONSchema = function toJSONSchema(options) {
|
|
|
3119
3119
|
for (const path of Object.keys(this.paths)) {
|
|
3120
3120
|
const schemaType = this.paths[path];
|
|
3121
3121
|
|
|
3122
|
-
// Skip Map embedded paths, maps will be handled
|
|
3122
|
+
// Skip Map embedded paths, maps will be handled separately.
|
|
3123
3123
|
if (schemaType._presplitPath.indexOf('$*') !== -1) {
|
|
3124
3124
|
continue;
|
|
3125
3125
|
}
|
package/lib/schemaType.js
CHANGED
|
@@ -99,11 +99,11 @@ function SchemaType(path, options, instance, parentSchema) {
|
|
|
99
99
|
const index = this._index;
|
|
100
100
|
if (typeof index === 'object' && index != null) {
|
|
101
101
|
if (index.unique) {
|
|
102
|
-
throw new
|
|
102
|
+
throw new MongooseError('Path "' + this.path + '" may not have `index` ' +
|
|
103
103
|
'set to false and `unique` set to true');
|
|
104
104
|
}
|
|
105
105
|
if (index.sparse) {
|
|
106
|
-
throw new
|
|
106
|
+
throw new MongooseError('Path "' + this.path + '" may not have `index` ' +
|
|
107
107
|
'set to false and `sparse` set to true');
|
|
108
108
|
}
|
|
109
109
|
}
|
|
@@ -317,7 +317,7 @@ SchemaType.prototype.castFunction = function castFunction(caster, message) {
|
|
|
317
317
|
*/
|
|
318
318
|
|
|
319
319
|
SchemaType.prototype.cast = function cast() {
|
|
320
|
-
throw new
|
|
320
|
+
throw new MongooseError('Base SchemaType class does not implement a `cast()` function');
|
|
321
321
|
};
|
|
322
322
|
|
|
323
323
|
/**
|
|
@@ -491,7 +491,7 @@ SchemaType.prototype.unique = function unique(value, message) {
|
|
|
491
491
|
if (!value) {
|
|
492
492
|
return;
|
|
493
493
|
}
|
|
494
|
-
throw new
|
|
494
|
+
throw new MongooseError('Path "' + this.path + '" may not have `index` set to ' +
|
|
495
495
|
'false and `unique` set to true');
|
|
496
496
|
}
|
|
497
497
|
|
|
@@ -530,7 +530,7 @@ SchemaType.prototype.text = function(bool) {
|
|
|
530
530
|
if (!bool) {
|
|
531
531
|
return this;
|
|
532
532
|
}
|
|
533
|
-
throw new
|
|
533
|
+
throw new MongooseError('Path "' + this.path + '" may not have `index` set to ' +
|
|
534
534
|
'false and `text` set to true');
|
|
535
535
|
}
|
|
536
536
|
|
|
@@ -567,7 +567,7 @@ SchemaType.prototype.sparse = function(bool) {
|
|
|
567
567
|
if (!bool) {
|
|
568
568
|
return this;
|
|
569
569
|
}
|
|
570
|
-
throw new
|
|
570
|
+
throw new MongooseError('Path "' + this.path + '" may not have `index` set to ' +
|
|
571
571
|
'false and `sparse` set to true');
|
|
572
572
|
}
|
|
573
573
|
|
|
@@ -1003,7 +1003,7 @@ SchemaType.prototype.validate = function(obj, message, type) {
|
|
|
1003
1003
|
+ arg
|
|
1004
1004
|
+ '. See https://mongoosejs.com/docs/api/schematype.html#SchemaType.prototype.validate()';
|
|
1005
1005
|
|
|
1006
|
-
throw new
|
|
1006
|
+
throw new MongooseError(msg);
|
|
1007
1007
|
}
|
|
1008
1008
|
this.validate(arg.validator, arg);
|
|
1009
1009
|
}
|
|
@@ -1704,7 +1704,7 @@ SchemaType.prototype.castForQuery = function($conditional, val, context) {
|
|
|
1704
1704
|
if ($conditional != null) {
|
|
1705
1705
|
handler = this.$conditionalHandlers[$conditional];
|
|
1706
1706
|
if (!handler) {
|
|
1707
|
-
throw new
|
|
1707
|
+
throw new MongooseError('Can\'t use ' + $conditional);
|
|
1708
1708
|
}
|
|
1709
1709
|
return handler.call(this, val, context);
|
|
1710
1710
|
}
|
|
@@ -1820,7 +1820,7 @@ SchemaType.prototype._duplicateKeyErrorMessage = null;
|
|
|
1820
1820
|
*/
|
|
1821
1821
|
|
|
1822
1822
|
SchemaType.prototype.toJSONSchema = function toJSONSchema(_options) { // eslint-disable-line no-unused-vars
|
|
1823
|
-
throw new
|
|
1823
|
+
throw new MongooseError(`Converting unsupported SchemaType to JSON Schema: ${this.instance} at path "${this.path}"`);
|
|
1824
1824
|
};
|
|
1825
1825
|
|
|
1826
1826
|
/**
|
package/package.json
CHANGED
package/types/utility.d.ts
CHANGED
|
@@ -103,7 +103,7 @@ declare module 'mongoose' {
|
|
|
103
103
|
? T
|
|
104
104
|
: Omit<T, keyof U> & U;
|
|
105
105
|
|
|
106
|
-
type MergeType<A, B> = Omit<A, keyof B> & B;
|
|
106
|
+
type MergeType<A, B> = A extends unknown ? Omit<A, keyof B> & B : never;
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
109
|
* @summary Converts Unions to one record "object".
|