mongoose 9.2.2 → 9.2.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/lib/aggregate.js +41 -41
- package/lib/cast/bigint.js +2 -2
- package/lib/cast/boolean.js +3 -3
- package/lib/cast/double.js +2 -2
- package/lib/cast/int32.js +2 -2
- package/lib/cast/number.js +2 -2
- package/lib/cast/string.js +2 -2
- package/lib/cast.js +6 -6
- package/lib/collection.js +4 -4
- package/lib/connection.js +58 -58
- package/lib/cursor/aggregationCursor.js +6 -6
- package/lib/cursor/queryCursor.js +7 -7
- package/lib/document.js +176 -176
- package/lib/drivers/node-mongodb-native/collection.js +2 -2
- package/lib/drivers/node-mongodb-native/connection.js +8 -8
- package/lib/error/cast.js +2 -2
- package/lib/error/createCollectionsError.js +2 -2
- package/lib/error/divergentArray.js +1 -1
- package/lib/error/eachAsyncMultiError.js +1 -1
- package/lib/error/index.js +2 -2
- package/lib/error/invalidSchemaOption.js +1 -1
- package/lib/error/missingSchema.js +1 -1
- package/lib/error/objectParameter.js +3 -3
- package/lib/error/overwriteModel.js +1 -1
- package/lib/error/setOptionError.js +3 -3
- package/lib/error/strict.js +3 -3
- package/lib/error/strictPopulate.js +2 -2
- package/lib/error/syncIndexes.js +2 -2
- package/lib/error/validation.js +2 -2
- package/lib/error/validator.js +1 -1
- package/lib/error/version.js +2 -2
- package/lib/helpers/buildMiddlewareFilter.js +2 -2
- package/lib/helpers/clone.js +4 -4
- package/lib/helpers/createJSONSchemaTypeDefinition.js +4 -4
- package/lib/helpers/cursor/eachAsync.js +3 -3
- package/lib/helpers/discriminator/getDiscriminatorByValue.js +1 -1
- package/lib/helpers/discriminator/mergeDiscriminatorSchema.js +3 -3
- package/lib/helpers/document/applyTimestamps.js +9 -9
- package/lib/helpers/document/applyVirtuals.js +6 -6
- package/lib/helpers/document/compile.js +10 -10
- package/lib/helpers/document/getDeepestSubdocumentForPath.js +2 -2
- package/lib/helpers/document/getEmbeddedDiscriminatorPath.js +2 -2
- package/lib/helpers/indexes/isIndexEqual.js +3 -3
- package/lib/helpers/indexes/isIndexSpecEqual.js +3 -3
- package/lib/helpers/isMongooseObject.js +1 -1
- package/lib/helpers/isObject.js +2 -2
- package/lib/helpers/isSimpleValidator.js +2 -2
- package/lib/helpers/minimize.js +2 -2
- package/lib/helpers/model/applyHooks.js +1 -1
- package/lib/helpers/model/castBulkWrite.js +2 -2
- package/lib/helpers/pluralize.js +1 -1
- package/lib/helpers/populate/assignRawDocsToIdStructure.js +2 -2
- package/lib/helpers/populate/assignVals.js +6 -6
- package/lib/helpers/populate/createPopulateQueryFilter.js +2 -2
- package/lib/helpers/populate/getModelsMapForPopulate.js +12 -12
- package/lib/helpers/populate/getSchemaTypes.js +1 -1
- package/lib/helpers/populate/markArraySubdocsPopulated.js +1 -1
- package/lib/helpers/populate/setPopulatedVirtualValue.js +5 -5
- package/lib/helpers/projection/hasIncludedChildren.js +1 -1
- package/lib/helpers/projection/isPathExcluded.js +3 -3
- package/lib/helpers/projection/isSubpath.js +1 -1
- package/lib/helpers/query/castUpdate.js +14 -14
- package/lib/helpers/query/getEmbeddedDiscriminatorPath.js +4 -4
- package/lib/helpers/query/handleImmutable.js +6 -6
- package/lib/helpers/schema/getIndexes.js +1 -1
- package/lib/helpers/schema/getSubdocumentStrictValue.js +1 -1
- package/lib/helpers/setDefaultsOnInsert.js +3 -3
- package/lib/helpers/update/modifiedPaths.js +2 -2
- package/lib/helpers/updateValidators.js +2 -2
- package/lib/model.js +263 -263
- package/lib/mongoose.js +54 -54
- package/lib/options/schemaArrayOptions.js +2 -2
- package/lib/options/schemaBufferOptions.js +1 -1
- package/lib/options/schemaNumberOptions.js +3 -3
- package/lib/options/schemaObjectIdOptions.js +2 -2
- package/lib/options/schemaStringOptions.js +6 -6
- package/lib/options/schemaTypeOptions.js +13 -13
- package/lib/options/virtualOptions.js +11 -11
- package/lib/query.js +222 -222
- package/lib/queryHelpers.js +4 -4
- package/lib/schema/array.js +18 -18
- package/lib/schema/bigint.js +13 -13
- package/lib/schema/boolean.js +13 -13
- package/lib/schema/buffer.js +14 -14
- package/lib/schema/date.js +16 -16
- package/lib/schema/decimal128.js +13 -13
- package/lib/schema/documentArray.js +15 -15
- package/lib/schema/documentArrayElement.js +5 -6
- package/lib/schema/double.js +12 -12
- package/lib/schema/int32.js +13 -13
- package/lib/schema/map.js +10 -10
- package/lib/schema/mixed.js +10 -10
- package/lib/schema/number.js +18 -18
- package/lib/schema/objectId.js +14 -14
- package/lib/schema/operators/text.js +3 -3
- package/lib/schema/string.js +17 -17
- package/lib/schema/subdocument.js +13 -13
- package/lib/schema/union.js +3 -3
- package/lib/schema/uuid.js +16 -16
- package/lib/schema.js +76 -76
- package/lib/schemaType.js +62 -62
- package/lib/stateMachine.js +5 -8
- package/lib/types/array/index.js +1 -1
- package/lib/types/array/methods/index.js +12 -12
- package/lib/types/arraySubdocument.js +8 -8
- package/lib/types/buffer.js +4 -4
- package/lib/types/documentArray/index.js +1 -1
- package/lib/types/documentArray/methods/index.js +5 -5
- package/lib/types/map.js +3 -3
- package/lib/types/subdocument.js +11 -11
- package/lib/utils.js +45 -45
- package/lib/virtualType.js +18 -18
- package/package.json +8 -5
- package/types/index.d.ts +16 -15
- package/types/inferschematype.d.ts +10 -0
- package/types/models.d.ts +8 -5
- package/types/schemaoptions.d.ts +1 -1
- package/types/virtuals.d.ts +10 -10
|
@@ -82,7 +82,7 @@ NativeCollection.prototype._getCollection = function _getCollection() {
|
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
84
|
* Copy the collection methods and make them subject to queues
|
|
85
|
-
* @param {
|
|
85
|
+
* @param {number|string} I
|
|
86
86
|
* @api private
|
|
87
87
|
*/
|
|
88
88
|
|
|
@@ -278,7 +278,7 @@ NativeCollection.prototype.$format = function(arg, color, shell) {
|
|
|
278
278
|
|
|
279
279
|
/**
|
|
280
280
|
* Debug print helper
|
|
281
|
-
* @param {
|
|
281
|
+
* @param {any} representation
|
|
282
282
|
* @api private
|
|
283
283
|
*/
|
|
284
284
|
|
|
@@ -52,9 +52,9 @@ Object.setPrototypeOf(NativeConnection.prototype, MongooseConnection.prototype);
|
|
|
52
52
|
*
|
|
53
53
|
* **Note:** Calling `close()` on a `useDb()` connection will close the base connection as well.
|
|
54
54
|
*
|
|
55
|
-
* @param {
|
|
56
|
-
* @param {
|
|
57
|
-
* @param {
|
|
55
|
+
* @param {string} name The database name
|
|
56
|
+
* @param {object} [options]
|
|
57
|
+
* @param {boolean} [options.useCache=false] If true, cache results so calling `useDb()` multiple times with the same name only creates 1 connection object.
|
|
58
58
|
* @return {Connection} New Connection Object
|
|
59
59
|
* @api public
|
|
60
60
|
*/
|
|
@@ -130,7 +130,7 @@ NativeConnection.prototype.useDb = function(name, options) {
|
|
|
130
130
|
* Runs a [db-level aggregate()](https://www.mongodb.com/docs/manual/reference/method/db.aggregate/) on this connection's underlying `db`
|
|
131
131
|
*
|
|
132
132
|
* @param {Array} pipeline
|
|
133
|
-
* @param {
|
|
133
|
+
* @param {object} [options]
|
|
134
134
|
*/
|
|
135
135
|
|
|
136
136
|
NativeConnection.prototype.aggregate = function aggregate(pipeline, options) {
|
|
@@ -155,7 +155,7 @@ NativeConnection.prototype.aggregate = function aggregate(pipeline, options) {
|
|
|
155
155
|
*
|
|
156
156
|
* @method removeDb
|
|
157
157
|
* @memberOf Connection
|
|
158
|
-
* @param {
|
|
158
|
+
* @param {string} name The database name
|
|
159
159
|
* @return {Connection} this
|
|
160
160
|
*/
|
|
161
161
|
|
|
@@ -178,7 +178,7 @@ NativeConnection.prototype.removeDb = function removeDb(name) {
|
|
|
178
178
|
/**
|
|
179
179
|
* Closes the connection
|
|
180
180
|
*
|
|
181
|
-
* @param {
|
|
181
|
+
* @param {boolean} [force]
|
|
182
182
|
* @return {Connection} this
|
|
183
183
|
* @api private
|
|
184
184
|
*/
|
|
@@ -211,7 +211,7 @@ NativeConnection.prototype.doClose = async function doClose(force) {
|
|
|
211
211
|
/**
|
|
212
212
|
* Implementation of `listDatabases()` for MongoDB driver
|
|
213
213
|
*
|
|
214
|
-
* @return Promise
|
|
214
|
+
* @return {Promise}
|
|
215
215
|
* @api public
|
|
216
216
|
*/
|
|
217
217
|
|
|
@@ -354,7 +354,7 @@ NativeConnection.prototype.createClient = async function createClient(uri, optio
|
|
|
354
354
|
* a schemaMap and/or an encryptedFieldsMap for the connection, combining all models
|
|
355
355
|
* into a single schemaMap and encryptedFields map.
|
|
356
356
|
*
|
|
357
|
-
* @returns the generated schemaMap and encryptedFieldsMap
|
|
357
|
+
* @returns {object} the generated schemaMap and encryptedFieldsMap
|
|
358
358
|
*/
|
|
359
359
|
NativeConnection.prototype._buildEncryptionSchemas = function() {
|
|
360
360
|
const qeMappings = {};
|
package/lib/error/cast.js
CHANGED
|
@@ -5,8 +5,8 @@ const MongooseError = require('./mongooseError');
|
|
|
5
5
|
/**
|
|
6
6
|
* createCollections Error constructor
|
|
7
7
|
*
|
|
8
|
-
* @param {
|
|
9
|
-
* @param {
|
|
8
|
+
* @param {string} message
|
|
9
|
+
* @param {string} errorsMap
|
|
10
10
|
* @inherits MongooseError
|
|
11
11
|
* @api private
|
|
12
12
|
*/
|
|
@@ -17,7 +17,7 @@ const MongooseError = require('./mongooseError');
|
|
|
17
17
|
|
|
18
18
|
class EachAsyncMultiError extends MongooseError {
|
|
19
19
|
/**
|
|
20
|
-
* @param {
|
|
20
|
+
* @param {string} connectionString
|
|
21
21
|
*/
|
|
22
22
|
constructor(errors) {
|
|
23
23
|
let preview = errors.map(e => e.message).join(', ');
|
package/lib/error/index.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* err instanceof mongoose.Error.ValidationError; // true
|
|
14
14
|
*
|
|
15
15
|
* @constructor Error
|
|
16
|
-
* @param {
|
|
16
|
+
* @param {string} msg Error message
|
|
17
17
|
* @inherits Error https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error
|
|
18
18
|
*/
|
|
19
19
|
|
|
@@ -39,7 +39,7 @@ const MongooseError = require('./mongooseError');
|
|
|
39
39
|
* - `VersionError`: Thrown when the [document is out of sync](https://mongoosejs.com/docs/guide.html#versionKey)
|
|
40
40
|
*
|
|
41
41
|
* @api public
|
|
42
|
-
* @property {
|
|
42
|
+
* @property {string} name
|
|
43
43
|
* @memberOf Error
|
|
44
44
|
* @instance
|
|
45
45
|
*/
|
|
@@ -10,9 +10,9 @@ const MongooseError = require('./mongooseError');
|
|
|
10
10
|
* Constructor for errors that happen when a parameter that's expected to be
|
|
11
11
|
* an object isn't an object
|
|
12
12
|
*
|
|
13
|
-
* @param {
|
|
14
|
-
* @param {
|
|
15
|
-
* @param {
|
|
13
|
+
* @param {any} value
|
|
14
|
+
* @param {string} paramName
|
|
15
|
+
* @param {string} fnName
|
|
16
16
|
* @api private
|
|
17
17
|
*/
|
|
18
18
|
|
|
@@ -40,8 +40,8 @@ class SetOptionError extends MongooseError {
|
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* add message
|
|
43
|
-
* @param {
|
|
44
|
-
* @param {
|
|
43
|
+
* @param {string} key
|
|
44
|
+
* @param {string|Error} error
|
|
45
45
|
* @api private
|
|
46
46
|
*/
|
|
47
47
|
addError(key, error) {
|
|
@@ -87,7 +87,7 @@ Object.defineProperty(SetOptionError.prototype, 'name', {
|
|
|
87
87
|
class SetOptionInnerError extends MongooseError {
|
|
88
88
|
/**
|
|
89
89
|
* Error for the "errors" array in "SetOptionError" with consistent message
|
|
90
|
-
* @param {
|
|
90
|
+
* @param {string} key
|
|
91
91
|
*/
|
|
92
92
|
constructor(key) {
|
|
93
93
|
super(`"${key}" is not a valid option to set`);
|
package/lib/error/strict.js
CHANGED
|
@@ -9,9 +9,9 @@ const MongooseError = require('./mongooseError');
|
|
|
9
9
|
/**
|
|
10
10
|
* Strict mode error constructor
|
|
11
11
|
*
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {
|
|
14
|
-
* @param {
|
|
12
|
+
* @param {string} path
|
|
13
|
+
* @param {string} [msg]
|
|
14
|
+
* @param {boolean} [immutable]
|
|
15
15
|
* @inherits MongooseError
|
|
16
16
|
* @api private
|
|
17
17
|
*/
|
package/lib/error/syncIndexes.js
CHANGED
|
@@ -9,8 +9,8 @@ const MongooseError = require('./mongooseError');
|
|
|
9
9
|
/**
|
|
10
10
|
* SyncIndexes Error constructor.
|
|
11
11
|
*
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {
|
|
12
|
+
* @param {string} message
|
|
13
|
+
* @param {string} errorsMap
|
|
14
14
|
* @inherits MongooseError
|
|
15
15
|
* @api private
|
|
16
16
|
*/
|
package/lib/error/validation.js
CHANGED
package/lib/error/validator.js
CHANGED
package/lib/error/version.js
CHANGED
|
@@ -10,8 +10,8 @@ const MongooseError = require('./mongooseError');
|
|
|
10
10
|
* Version Error constructor.
|
|
11
11
|
*
|
|
12
12
|
* @param {Document} doc
|
|
13
|
-
* @param {
|
|
14
|
-
* @param {
|
|
13
|
+
* @param {number} currentVersion
|
|
14
|
+
* @param {string[]} modifiedPaths
|
|
15
15
|
* @api private
|
|
16
16
|
*/
|
|
17
17
|
|
|
@@ -10,8 +10,8 @@ const isBuiltInMiddleware = hook => hook.fn[symbols.builtInMiddleware];
|
|
|
10
10
|
/**
|
|
11
11
|
* Builds a filter for kareem's execPre/execPost based on middleware options.
|
|
12
12
|
*
|
|
13
|
-
* @param {
|
|
14
|
-
* @param {
|
|
13
|
+
* @param {object} options - Options object that may contain `middleware` setting
|
|
14
|
+
* @param {string} phase - Either 'pre' or 'post'
|
|
15
15
|
* @returns {Function|null} - null runs all middleware, isBuiltInMiddleware skips user middleware
|
|
16
16
|
*/
|
|
17
17
|
function buildMiddlewareFilter(options, phase) {
|
package/lib/helpers/clone.js
CHANGED
|
@@ -23,10 +23,10 @@ const Binary = BSON.Binary;
|
|
|
23
23
|
*
|
|
24
24
|
* Functions and primitives are never cloned.
|
|
25
25
|
*
|
|
26
|
-
* @param {
|
|
27
|
-
* @param {
|
|
28
|
-
* @param {
|
|
29
|
-
* @return {
|
|
26
|
+
* @param {object} obj the object to clone
|
|
27
|
+
* @param {object} options
|
|
28
|
+
* @param {boolean} isArrayChild true if cloning immediately underneath an array. Special case for minimize.
|
|
29
|
+
* @return {object} the cloned object
|
|
30
30
|
* @api private
|
|
31
31
|
*/
|
|
32
32
|
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* Handles creating `{ type: 'object' }` vs `{ bsonType: 'object' }` vs `{ bsonType: ['object', 'null'] }`
|
|
5
5
|
*
|
|
6
|
-
* @param {
|
|
7
|
-
* @param {
|
|
8
|
-
* @param {
|
|
9
|
-
* @param {
|
|
6
|
+
* @param {string} type
|
|
7
|
+
* @param {string} bsonType
|
|
8
|
+
* @param {boolean} useBsonType
|
|
9
|
+
* @param {boolean} isRequired
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
module.exports = function createJSONSchemaTypeArray(type, bsonType, useBsonType, isRequired) {
|
|
@@ -14,9 +14,9 @@ const immediate = require('../immediate');
|
|
|
14
14
|
*
|
|
15
15
|
* @param {Function} next the thunk to call to get the next document
|
|
16
16
|
* @param {Function} fn
|
|
17
|
-
* @param {
|
|
18
|
-
* @param {
|
|
19
|
-
* @param {
|
|
17
|
+
* @param {object} options
|
|
18
|
+
* @param {number} [options.batchSize=null] if set, Mongoose will call `fn` with an array of at most `batchSize` documents, instead of a single document
|
|
19
|
+
* @param {number} [options.parallel=1] maximum number of `fn` calls that Mongoose will run in parallel
|
|
20
20
|
* @param {AbortSignal} [options.signal] allow cancelling this eachAsync(). Once the abort signal is fired, `eachAsync()` will immediately fulfill the returned promise (or call the callback) and not fetch any more documents.
|
|
21
21
|
* @return {Promise}
|
|
22
22
|
* @api public
|
|
@@ -8,9 +8,9 @@ const isObject = require('../../helpers/isObject');
|
|
|
8
8
|
/**
|
|
9
9
|
* Merges `from` into `to` without overwriting existing properties.
|
|
10
10
|
*
|
|
11
|
-
* @param {
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {
|
|
11
|
+
* @param {object} to
|
|
12
|
+
* @param {object} from
|
|
13
|
+
* @param {string} [path]
|
|
14
14
|
* @api private
|
|
15
15
|
*/
|
|
16
16
|
|
|
@@ -10,9 +10,9 @@ module.exports = applyTimestamps;
|
|
|
10
10
|
* Apply a given schema's timestamps to the given POJO
|
|
11
11
|
*
|
|
12
12
|
* @param {Schema} schema
|
|
13
|
-
* @param {
|
|
14
|
-
* @param {
|
|
15
|
-
* @param {
|
|
13
|
+
* @param {object} obj
|
|
14
|
+
* @param {object} [options]
|
|
15
|
+
* @param {boolean} [options.isUpdate=false] if true, treat this as an update: just set updatedAt, skip setting createdAt. If false, set both createdAt and updatedAt
|
|
16
16
|
* @param {Function} [options.currentTime] if set, Mongoose will call this function to get the current time.
|
|
17
17
|
*/
|
|
18
18
|
|
|
@@ -29,9 +29,9 @@ function applyTimestamps(schema, obj, options) {
|
|
|
29
29
|
* Apply timestamps to any subdocuments
|
|
30
30
|
*
|
|
31
31
|
* @param {Schema} schema subdocument schema
|
|
32
|
-
* @param {
|
|
33
|
-
* @param {
|
|
34
|
-
* @param {
|
|
32
|
+
* @param {object} res subdocument
|
|
33
|
+
* @param {object} [options]
|
|
34
|
+
* @param {boolean} [options.isUpdate=false] if true, treat this as an update: just set updatedAt, skip setting createdAt. If false, set both createdAt and updatedAt
|
|
35
35
|
* @param {Function} [options.currentTime] if set, Mongoose will call this function to get the current time.
|
|
36
36
|
*/
|
|
37
37
|
|
|
@@ -55,9 +55,9 @@ function applyTimestampsToChildren(schema, res, options) {
|
|
|
55
55
|
* Apply timestamps to a given document. Does not apply timestamps to subdocuments: use `applyTimestampsToChildren` instead
|
|
56
56
|
*
|
|
57
57
|
* @param {Schema} schema
|
|
58
|
-
* @param {
|
|
59
|
-
* @param {
|
|
60
|
-
* @param {
|
|
58
|
+
* @param {object} obj
|
|
59
|
+
* @param {object} [options]
|
|
60
|
+
* @param {boolean} [options.isUpdate=false] if true, treat this as an update: just set updatedAt, skip setting createdAt. If false, set both createdAt and updatedAt
|
|
61
61
|
* @param {Function} [options.currentTime] if set, Mongoose will call this function to get the current time.
|
|
62
62
|
*/
|
|
63
63
|
|
|
@@ -9,8 +9,8 @@ module.exports = applyVirtuals;
|
|
|
9
9
|
* Apply a given schema's virtuals to a given POJO
|
|
10
10
|
*
|
|
11
11
|
* @param {Schema} schema
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {
|
|
12
|
+
* @param {object} obj
|
|
13
|
+
* @param {string[]} [virtuals] optional whitelist of virtuals to apply
|
|
14
14
|
* @returns
|
|
15
15
|
*/
|
|
16
16
|
|
|
@@ -42,8 +42,8 @@ function applyVirtuals(schema, obj, virtuals) {
|
|
|
42
42
|
* Apply virtuals to any subdocuments
|
|
43
43
|
*
|
|
44
44
|
* @param {Schema} schema subdocument schema
|
|
45
|
-
* @param {
|
|
46
|
-
* @param {
|
|
45
|
+
* @param {object} res subdocument
|
|
46
|
+
* @param {string[]} [virtuals] optional whitelist of virtuals to apply
|
|
47
47
|
*/
|
|
48
48
|
|
|
49
49
|
function applyVirtualsToChildren(schema, res, virtuals) {
|
|
@@ -86,8 +86,8 @@ function applyVirtualsToChildren(schema, res, virtuals) {
|
|
|
86
86
|
* Apply virtuals to a given document. Does not apply virtuals to subdocuments: use `applyVirtualsToChildren` instead
|
|
87
87
|
*
|
|
88
88
|
* @param {Schema} schema
|
|
89
|
-
* @param {
|
|
90
|
-
* @param {
|
|
89
|
+
* @param {object} doc
|
|
90
|
+
* @param {string[]} [virtuals] optional whitelist of virtuals to apply
|
|
91
91
|
* @returns
|
|
92
92
|
*/
|
|
93
93
|
|
|
@@ -31,10 +31,10 @@ const noDottedPathGetOptions = Object.freeze({
|
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Compiles schemas.
|
|
34
|
-
* @param {
|
|
35
|
-
* @param {
|
|
36
|
-
* @param {
|
|
37
|
-
* @param {
|
|
34
|
+
* @param {object} tree
|
|
35
|
+
* @param {any} proto
|
|
36
|
+
* @param {string} prefix
|
|
37
|
+
* @param {object} options
|
|
38
38
|
* @api private
|
|
39
39
|
*/
|
|
40
40
|
|
|
@@ -56,12 +56,12 @@ function compile(tree, proto, prefix, options) {
|
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
58
|
* Defines the accessor named prop on the incoming prototype.
|
|
59
|
-
* @param {
|
|
60
|
-
* @param {
|
|
61
|
-
* @param {
|
|
62
|
-
* @param {
|
|
63
|
-
* @param {
|
|
64
|
-
* @param {
|
|
59
|
+
* @param {object} options
|
|
60
|
+
* @param {string} options.prop
|
|
61
|
+
* @param {boolean} options.subprops
|
|
62
|
+
* @param {any} options.prototype
|
|
63
|
+
* @param {string} [options.prefix]
|
|
64
|
+
* @param {object} options.options
|
|
65
65
|
* @api private
|
|
66
66
|
*/
|
|
67
67
|
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
* document.
|
|
7
7
|
*
|
|
8
8
|
* @param {Document} doc
|
|
9
|
-
* @param {
|
|
9
|
+
* @param {string[]} parts
|
|
10
10
|
* @param {Schema} schema
|
|
11
|
-
* @returns Document
|
|
11
|
+
* @returns {Document}
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
module.exports = function getDeepestSubdocumentForPath(doc, parts, schema) {
|
|
@@ -8,8 +8,8 @@ const getSchemaDiscriminatorByValue = require('../discriminator/getSchemaDiscrim
|
|
|
8
8
|
* determine path type without knowing the embedded discriminator key.
|
|
9
9
|
*
|
|
10
10
|
* @param {Document} doc
|
|
11
|
-
* @param {
|
|
12
|
-
* @param {
|
|
11
|
+
* @param {string|string[]} path
|
|
12
|
+
* @param {object} [options]
|
|
13
13
|
* @api private
|
|
14
14
|
*/
|
|
15
15
|
|
|
@@ -6,9 +6,9 @@ const utils = require('../../utils');
|
|
|
6
6
|
* Given a Mongoose index definition (key + options objects) and a MongoDB server
|
|
7
7
|
* index definition, determine if the two indexes are equal.
|
|
8
8
|
*
|
|
9
|
-
* @param {
|
|
10
|
-
* @param {
|
|
11
|
-
* @param {
|
|
9
|
+
* @param {object} schemaIndexKeysObject the Mongoose index spec
|
|
10
|
+
* @param {object} options the Mongoose index definition's options
|
|
11
|
+
* @param {object} dbIndex the index in MongoDB as returned by `listIndexes()`
|
|
12
12
|
* @api private
|
|
13
13
|
*/
|
|
14
14
|
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
* isIndexSpecEqual({ a: 1, b: 1 }, { b: 1, a: 1 }); // false
|
|
9
9
|
* isIndexSpecEqual({ a: 1, b: -1 }, { a: 1, b: 1 }); // false
|
|
10
10
|
*
|
|
11
|
-
* @param {
|
|
12
|
-
* @param {
|
|
13
|
-
* @returns {
|
|
11
|
+
* @param {object} spec1 The first index specification to compare.
|
|
12
|
+
* @param {object} spec2 The second index specification to compare.
|
|
13
|
+
* @returns {boolean} Returns true if the index specifications are equal, otherwise returns false.
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
module.exports = function isIndexSpecEqual(spec1, spec2) {
|
package/lib/helpers/isObject.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* Determines if `arg` is an object.
|
|
5
5
|
*
|
|
6
|
-
* @param {
|
|
6
|
+
* @param {object|Array|string|Function|RegExp|any} arg
|
|
7
7
|
* @api private
|
|
8
|
-
* @return {
|
|
8
|
+
* @return {boolean}
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
module.exports = function(arg) {
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* Determines if `arg` is a flat object.
|
|
5
5
|
*
|
|
6
|
-
* @param {
|
|
6
|
+
* @param {object|Array|string|Function|RegExp|any} arg
|
|
7
7
|
* @api private
|
|
8
|
-
* @return {
|
|
8
|
+
* @return {boolean}
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
module.exports = function isSimpleValidator(obj) {
|
package/lib/helpers/minimize.js
CHANGED
|
@@ -7,8 +7,8 @@ module.exports = minimize;
|
|
|
7
7
|
/**
|
|
8
8
|
* Minimizes an object, removing undefined values and empty objects
|
|
9
9
|
*
|
|
10
|
-
* @param {
|
|
11
|
-
* @return {
|
|
10
|
+
* @param {object} object to minimize
|
|
11
|
+
* @return {object|undefined}
|
|
12
12
|
* @api private
|
|
13
13
|
*/
|
|
14
14
|
|
|
@@ -15,8 +15,8 @@ const setDefaultsOnInsert = require('../setDefaultsOnInsert');
|
|
|
15
15
|
* Given a model and a bulkWrite op, return a thunk that handles casting and
|
|
16
16
|
* validating the individual op.
|
|
17
17
|
* @param {Model} originalModel
|
|
18
|
-
* @param {
|
|
19
|
-
* @param {
|
|
18
|
+
* @param {object} op
|
|
19
|
+
* @param {object} [options]
|
|
20
20
|
* @api private
|
|
21
21
|
*/
|
|
22
22
|
|
package/lib/helpers/pluralize.js
CHANGED
|
@@ -26,8 +26,8 @@ const kHasArray = Symbol('mongoose#assignRawDocsToIdStructure#hasArray');
|
|
|
26
26
|
* @param {Array} rawIds
|
|
27
27
|
* @param {Array} resultDocs
|
|
28
28
|
* @param {Array} resultOrder
|
|
29
|
-
* @param {
|
|
30
|
-
* @param {
|
|
29
|
+
* @param {object} options
|
|
30
|
+
* @param {boolean} recursed
|
|
31
31
|
* @api private
|
|
32
32
|
*/
|
|
33
33
|
|
|
@@ -256,11 +256,11 @@ function numDocs(v) {
|
|
|
256
256
|
* background:
|
|
257
257
|
* _ids are left in the query even when user excludes them so
|
|
258
258
|
* that population mapping can occur.
|
|
259
|
-
* @param {
|
|
260
|
-
* @param {
|
|
261
|
-
* @param {
|
|
259
|
+
* @param {any} val
|
|
260
|
+
* @param {object} assignmentOpts
|
|
261
|
+
* @param {object} populateOptions
|
|
262
262
|
* @param {Function} [populateOptions.transform]
|
|
263
|
-
* @param {
|
|
263
|
+
* @param {boolean} allIds
|
|
264
264
|
* @api private
|
|
265
265
|
*/
|
|
266
266
|
|
|
@@ -327,7 +327,7 @@ function valueFilter(val, assignmentOpts, populateOptions, allIds) {
|
|
|
327
327
|
/**
|
|
328
328
|
* Remove _id from `subdoc` if user specified "lean" query option
|
|
329
329
|
* @param {Document} subdoc
|
|
330
|
-
* @param {
|
|
330
|
+
* @param {object} assignmentOpts
|
|
331
331
|
* @api private
|
|
332
332
|
*/
|
|
333
333
|
|
|
@@ -344,7 +344,7 @@ function maybeRemoveId(subdoc, assignmentOpts) {
|
|
|
344
344
|
/**
|
|
345
345
|
* Determine if `obj` is something we can set a populated path to. Can be a
|
|
346
346
|
* document, a lean document, or an array/map that contains docs.
|
|
347
|
-
* @param {
|
|
347
|
+
* @param {any} obj
|
|
348
348
|
* @api private
|
|
349
349
|
*/
|
|
350
350
|
|