mongoose 6.3.9 → 6.4.2
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/.eslintrc.json +65 -36
- package/dist/browser.umd.js +68579 -2
- package/lib/cast/date.js +1 -1
- package/lib/cast/decimal128.js +1 -1
- package/lib/cast/objectid.js +1 -1
- package/lib/cast.js +1 -1
- package/lib/connection.js +47 -5
- package/lib/document.js +48 -8
- package/lib/drivers/node-mongodb-native/index.js +1 -1
- package/lib/error/parallelValidate.js +1 -1
- package/lib/helpers/aggregate/prepareDiscriminatorPipeline.js +1 -1
- package/lib/helpers/aggregate/stringifyFunctionOperators.js +1 -1
- package/lib/helpers/arrayDepth.js +1 -1
- package/lib/helpers/cursor/eachAsync.js +1 -1
- package/lib/helpers/discriminator/areDiscriminatorValuesEqual.js +1 -1
- package/lib/helpers/discriminator/checkEmbeddedDiscriminatorKeyProjection.js +1 -1
- package/lib/helpers/discriminator/getConstructor.js +1 -1
- package/lib/helpers/discriminator/getDiscriminatorByValue.js +1 -1
- package/lib/helpers/discriminator/getSchemaDiscriminatorByValue.js +1 -1
- package/lib/helpers/document/handleSpreadDoc.js +1 -1
- package/lib/helpers/each.js +1 -1
- package/lib/helpers/get.js +1 -1
- package/lib/helpers/getConstructorName.js +1 -1
- package/lib/helpers/getDefaultBulkwriteResult.js +1 -1
- package/lib/helpers/indexes/applySchemaCollation.js +1 -1
- package/lib/helpers/indexes/decorateDiscriminatorIndexOptions.js +1 -1
- package/lib/helpers/indexes/isDefaultIdIndex.js +1 -1
- package/lib/helpers/indexes/isTextIndex.js +1 -1
- package/lib/helpers/isMongooseObject.js +1 -1
- package/lib/helpers/isObject.js +1 -1
- package/lib/helpers/isPromise.js +1 -1
- package/lib/helpers/model/applyHooks.js +1 -1
- package/lib/helpers/model/applyStaticHooks.js +1 -1
- package/lib/helpers/once.js +1 -1
- package/lib/helpers/path/flattenObjectWithDottedPaths.js +1 -1
- package/lib/helpers/path/parentPaths.js +1 -1
- package/lib/helpers/path/setDottedPath.js +1 -1
- package/lib/helpers/pluralize.js +1 -1
- package/lib/helpers/populate/SkipPopulateValue.js +1 -1
- package/lib/helpers/populate/assignRawDocsToIdStructure.js +1 -1
- package/lib/helpers/populate/assignVals.js +1 -1
- package/lib/helpers/populate/createPopulateQueryFilter.js +1 -1
- package/lib/helpers/populate/getModelsMapForPopulate.js +1 -1
- package/lib/helpers/populate/leanPopulateMap.js +1 -1
- package/lib/helpers/populate/lookupLocalFields.js +1 -1
- package/lib/helpers/populate/markArraySubdocsPopulated.js +1 -1
- package/lib/helpers/populate/modelNamesFromRefPath.js +1 -1
- package/lib/helpers/populate/removeDeselectedForeignField.js +1 -1
- package/lib/helpers/populate/validateRef.js +1 -1
- package/lib/helpers/printJestWarning.js +1 -1
- package/lib/helpers/processConnectionOptions.js +1 -1
- package/lib/helpers/projection/applyProjection.js +1 -1
- package/lib/helpers/projection/hasIncludedChildren.js +1 -1
- package/lib/helpers/projection/parseProjection.js +1 -1
- package/lib/helpers/query/applyGlobalOption.js +1 -1
- package/lib/helpers/query/applyQueryMiddleware.js +1 -1
- package/lib/helpers/query/cast$expr.js +1 -1
- package/lib/helpers/query/castFilterPath.js +1 -1
- package/lib/helpers/query/sanitizeFilter.js +1 -1
- package/lib/helpers/query/sanitizeProjection.js +1 -1
- package/lib/helpers/query/trusted.js +1 -1
- package/lib/helpers/query/validOps.js +1 -1
- package/lib/helpers/query/wrapThunk.js +1 -1
- package/lib/helpers/schema/addAutoId.js +1 -1
- package/lib/helpers/schema/applyPlugins.js +1 -1
- package/lib/helpers/schema/cleanPositionalOperators.js +1 -1
- package/lib/helpers/schema/getKeysInSchemaOrder.js +1 -1
- package/lib/helpers/schema/getPath.js +1 -1
- package/lib/helpers/schema/handleIdOption.js +1 -1
- package/lib/helpers/schema/handleTimestampOption.js +1 -1
- package/lib/helpers/specialProperties.js +1 -1
- package/lib/helpers/symbols.js +1 -1
- package/lib/helpers/timers.js +1 -1
- package/lib/helpers/timestamps/setupTimestamps.js +5 -2
- package/lib/helpers/topology/allServersUnknown.js +1 -1
- package/lib/helpers/topology/isAtlas.js +1 -1
- package/lib/helpers/topology/isSSLError.js +1 -1
- package/lib/helpers/update/applyTimestampsToChildren.js +1 -1
- package/lib/helpers/update/castArrayFilters.js +1 -1
- package/lib/helpers/update/moveImmutableProperties.js +1 -1
- package/lib/helpers/update/removeUnusedArrayFilters.js +1 -1
- package/lib/helpers/update/updatedPathsByArrayFilter.js +1 -1
- package/lib/helpers/updateValidators.js +11 -18
- package/lib/index.js +108 -29
- package/lib/model.js +1 -1
- package/lib/options/PopulateOptions.js +1 -1
- package/lib/options/SchemaArrayOptions.js +1 -1
- package/lib/options/SchemaBufferOptions.js +1 -1
- package/lib/options/SchemaDocumentArrayOptions.js +1 -1
- package/lib/options/SchemaMapOptions.js +1 -1
- package/lib/options/SchemaNumberOptions.js +1 -1
- package/lib/options/SchemaObjectIdOptions.js +1 -1
- package/lib/options/SchemaSubdocumentOptions.js +1 -1
- package/lib/options/SchemaTypeOptions.js +1 -1
- package/lib/options/VirtualOptions.js +1 -1
- package/lib/options/propertyOptions.js +1 -1
- package/lib/options/removeOptions.js +1 -1
- package/lib/options/saveOptions.js +1 -1
- package/lib/plugins/trackTransaction.js +1 -1
- package/lib/query.js +61 -6
- package/lib/queryhelpers.js +5 -0
- package/lib/schema/array.js +1 -1
- package/lib/schema/date.js +2 -2
- package/lib/schema/documentarray.js +10 -0
- package/lib/schema/number.js +2 -2
- package/lib/schema/string.js +2 -2
- package/lib/schema/symbols.js +1 -1
- package/lib/schema.js +6 -7
- package/lib/statemachine.js +13 -0
- package/lib/types/DocumentArray/methods/index.js +1 -1
- package/lib/utils.js +3 -0
- package/lib/validoptions.js +1 -0
- package/package.json +3 -3
- package/tsconfig.json +1 -0
- package/types/collection.d.ts +1 -1
- package/types/connection.d.ts +5 -0
- package/types/document.d.ts +15 -6
- package/types/expressions.d.ts +2882 -0
- package/types/index.d.ts +46 -17
- package/types/{indizes.d.ts → indexes.d.ts} +2 -2
- package/types/inferschematype.d.ts +173 -0
- package/types/middlewares.d.ts +1 -1
- package/types/models.d.ts +86 -71
- package/types/mongooseoptions.d.ts +9 -1
- package/types/pipelinestage.d.ts +76 -80
- package/types/query.d.ts +1 -1
- package/types/schemaoptions.d.ts +22 -4
- package/types/types.d.ts +3 -1
- package/types/utility.d.ts +9 -0
package/lib/query.js
CHANGED
|
@@ -27,6 +27,7 @@ const immediate = require('./helpers/immediate');
|
|
|
27
27
|
const isExclusive = require('./helpers/projection/isExclusive');
|
|
28
28
|
const isInclusive = require('./helpers/projection/isInclusive');
|
|
29
29
|
const isSubpath = require('./helpers/projection/isSubpath');
|
|
30
|
+
const mpath = require('mpath');
|
|
30
31
|
const mquery = require('mquery');
|
|
31
32
|
const parseProjection = require('./helpers/projection/parseProjection');
|
|
32
33
|
const removeUnusedArrayFilters = require('./helpers/update/removeUnusedArrayFilters');
|
|
@@ -2196,7 +2197,6 @@ function _castArrayFilters(query) {
|
|
|
2196
2197
|
* @api private
|
|
2197
2198
|
*/
|
|
2198
2199
|
Query.prototype._find = wrapThunk(function(callback) {
|
|
2199
|
-
|
|
2200
2200
|
this._castConditions();
|
|
2201
2201
|
|
|
2202
2202
|
if (this.error() != null) {
|
|
@@ -2220,7 +2220,8 @@ Query.prototype._find = wrapThunk(function(callback) {
|
|
|
2220
2220
|
// Separate options to pass down to `completeMany()` in case we need to
|
|
2221
2221
|
// set a session on the document
|
|
2222
2222
|
const completeManyOptions = Object.assign({}, {
|
|
2223
|
-
session: this && this.options && this.options.session || null
|
|
2223
|
+
session: this && this.options && this.options.session || null,
|
|
2224
|
+
lean: mongooseOptions.lean || null
|
|
2224
2225
|
});
|
|
2225
2226
|
|
|
2226
2227
|
const cb = (err, docs) => {
|
|
@@ -2244,7 +2245,9 @@ Query.prototype._find = wrapThunk(function(callback) {
|
|
|
2244
2245
|
});
|
|
2245
2246
|
}
|
|
2246
2247
|
return mongooseOptions.lean ?
|
|
2247
|
-
|
|
2248
|
+
// call _completeManyLean here?
|
|
2249
|
+
_completeManyLean(_this.model.schema, docs, null, completeManyOptions, callback) :
|
|
2250
|
+
// callback(null, docs) :
|
|
2248
2251
|
completeMany(_this.model, docs, fields, userProvidedFields, completeManyOptions, callback);
|
|
2249
2252
|
}
|
|
2250
2253
|
|
|
@@ -2418,6 +2421,9 @@ Query.prototype._completeOne = function(doc, res, callback) {
|
|
|
2418
2421
|
const mongooseOptions = this._mongooseOptions;
|
|
2419
2422
|
// `rawResult`
|
|
2420
2423
|
const options = this.options;
|
|
2424
|
+
if (!options.lean && mongooseOptions.lean) {
|
|
2425
|
+
options.lean = mongooseOptions.lean;
|
|
2426
|
+
}
|
|
2421
2427
|
|
|
2422
2428
|
if (options.explain) {
|
|
2423
2429
|
return callback(null, doc);
|
|
@@ -2431,7 +2437,7 @@ Query.prototype._completeOne = function(doc, res, callback) {
|
|
|
2431
2437
|
}
|
|
2432
2438
|
}
|
|
2433
2439
|
return mongooseOptions.lean ?
|
|
2434
|
-
_completeOneLean(doc, res, options, callback) :
|
|
2440
|
+
_completeOneLean(model.schema, doc, null, res, options, callback) :
|
|
2435
2441
|
completeOne(model, doc, res, options, projection, userProvidedFields,
|
|
2436
2442
|
null, callback);
|
|
2437
2443
|
}
|
|
@@ -2442,7 +2448,7 @@ Query.prototype._completeOne = function(doc, res, callback) {
|
|
|
2442
2448
|
if (err != null) {
|
|
2443
2449
|
return callback(err);
|
|
2444
2450
|
}
|
|
2445
|
-
_completeOneLean(doc, res, options, callback);
|
|
2451
|
+
_completeOneLean(model.schema, doc, null, res, options, callback);
|
|
2446
2452
|
});
|
|
2447
2453
|
}
|
|
2448
2454
|
|
|
@@ -4009,13 +4015,62 @@ Query.prototype._findAndModify = function(type, callback) {
|
|
|
4009
4015
|
* ignore
|
|
4010
4016
|
*/
|
|
4011
4017
|
|
|
4012
|
-
function _completeOneLean(doc, res, opts, callback) {
|
|
4018
|
+
function _completeOneLean(schema, doc, path, res, opts, callback) {
|
|
4019
|
+
if (opts.lean && opts.lean.transform) {
|
|
4020
|
+
for (let i = 0; i < schema.childSchemas.length; i++) {
|
|
4021
|
+
const childPath = path ? path + '.' + schema.childSchemas[i].model.path : schema.childSchemas[i].model.path;
|
|
4022
|
+
const _schema = schema.childSchemas[i].schema;
|
|
4023
|
+
const obj = mpath.get(childPath, doc);
|
|
4024
|
+
if (obj == null) {
|
|
4025
|
+
continue;
|
|
4026
|
+
}
|
|
4027
|
+
if (Array.isArray(obj)) {
|
|
4028
|
+
for (let i = 0; i < obj.length; i++) {
|
|
4029
|
+
opts.lean.transform(obj[i]);
|
|
4030
|
+
}
|
|
4031
|
+
} else {
|
|
4032
|
+
opts.lean.transform(obj);
|
|
4033
|
+
}
|
|
4034
|
+
_completeOneLean(_schema, obj, childPath, res, opts);
|
|
4035
|
+
}
|
|
4036
|
+
if (callback) {
|
|
4037
|
+
return callback(null, doc);
|
|
4038
|
+
} else {
|
|
4039
|
+
return;
|
|
4040
|
+
}
|
|
4041
|
+
}
|
|
4013
4042
|
if (opts.rawResult) {
|
|
4014
4043
|
return callback(null, res);
|
|
4015
4044
|
}
|
|
4016
4045
|
return callback(null, doc);
|
|
4017
4046
|
}
|
|
4018
4047
|
|
|
4048
|
+
/*!
|
|
4049
|
+
* ignore
|
|
4050
|
+
*/
|
|
4051
|
+
|
|
4052
|
+
function _completeManyLean(schema, docs, path, opts, callback) {
|
|
4053
|
+
if (opts.lean && opts.lean.transform) {
|
|
4054
|
+
for (let i = 0; i < schema.childSchemas.length; i++) {
|
|
4055
|
+
const childPath = path ? path + '.' + schema.childSchemas[i].model.path : schema.childSchemas[i].model.path;
|
|
4056
|
+
const _schema = schema.childSchemas[i].schema;
|
|
4057
|
+
let doc = mpath.get(childPath, docs);
|
|
4058
|
+
if (doc == null) {
|
|
4059
|
+
continue;
|
|
4060
|
+
}
|
|
4061
|
+
doc = doc.flat();
|
|
4062
|
+
for (let i = 0; i < doc.length; i++) {
|
|
4063
|
+
opts.lean.transform(doc[i]);
|
|
4064
|
+
}
|
|
4065
|
+
_completeManyLean(_schema, doc, childPath, opts);
|
|
4066
|
+
}
|
|
4067
|
+
}
|
|
4068
|
+
|
|
4069
|
+
if (!callback) {
|
|
4070
|
+
return;
|
|
4071
|
+
}
|
|
4072
|
+
return callback(null, docs);
|
|
4073
|
+
}
|
|
4019
4074
|
/*!
|
|
4020
4075
|
* Override mquery.prototype._mergeUpdate to handle mongoose objects in
|
|
4021
4076
|
* updates.
|
package/lib/queryhelpers.js
CHANGED
|
@@ -209,6 +209,11 @@ exports.applyPaths = function applyPaths(fields, schema) {
|
|
|
209
209
|
// user didn't specify fields, implies returning all fields.
|
|
210
210
|
// only need to apply excluded fields and delete any plus paths
|
|
211
211
|
for (const fieldName of excluded) {
|
|
212
|
+
if (fields[fieldName] != null) {
|
|
213
|
+
// Skip applying default projections to fields with non-defining
|
|
214
|
+
// projections, like `$slice`
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
212
217
|
fields[fieldName] = 0;
|
|
213
218
|
}
|
|
214
219
|
break;
|
package/lib/schema/array.js
CHANGED
|
@@ -212,7 +212,7 @@ SchemaArray.checkRequired = SchemaType.checkRequired;
|
|
|
212
212
|
*/
|
|
213
213
|
|
|
214
214
|
SchemaArray.prototype.checkRequired = function checkRequired(value, doc) {
|
|
215
|
-
if (SchemaType._isRef(this, value, doc, true)) {
|
|
215
|
+
if (typeof value === 'object' && SchemaType._isRef(this, value, doc, true)) {
|
|
216
216
|
return !!value;
|
|
217
217
|
}
|
|
218
218
|
|
package/lib/schema/date.js
CHANGED
|
@@ -195,8 +195,8 @@ SchemaDate.checkRequired = SchemaType.checkRequired;
|
|
|
195
195
|
*/
|
|
196
196
|
|
|
197
197
|
SchemaDate.prototype.checkRequired = function(value, doc) {
|
|
198
|
-
if (SchemaType._isRef(this, value, doc, true)) {
|
|
199
|
-
return
|
|
198
|
+
if (typeof value === 'object' && SchemaType._isRef(this, value, doc, true)) {
|
|
199
|
+
return value != null;
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
// `require('util').inherits()` does **not** copy static properties, and
|
|
@@ -10,6 +10,7 @@ const EventEmitter = require('events').EventEmitter;
|
|
|
10
10
|
const SchemaDocumentArrayOptions =
|
|
11
11
|
require('../options/SchemaDocumentArrayOptions');
|
|
12
12
|
const SchemaType = require('../schematype');
|
|
13
|
+
const SubdocumentPath = require('./SubdocumentPath');
|
|
13
14
|
const discriminator = require('../helpers/model/discriminator');
|
|
14
15
|
const handleIdOption = require('../helpers/schema/handleIdOption');
|
|
15
16
|
const handleSpreadDoc = require('../helpers/document/handleSpreadDoc');
|
|
@@ -75,6 +76,15 @@ function DocumentArrayPath(key, schema, options, schemaOptions) {
|
|
|
75
76
|
this.$embeddedSchemaType.cast = function(value, doc, init) {
|
|
76
77
|
return parentSchemaType.cast(value, doc, init)[0];
|
|
77
78
|
};
|
|
79
|
+
this.$embeddedSchemaType.doValidate = function(value, fn, scope, options) {
|
|
80
|
+
const Constructor = getConstructor(this.caster, value);
|
|
81
|
+
|
|
82
|
+
if (value && !(value instanceof Constructor)) {
|
|
83
|
+
value = new Constructor(value, scope, null, null, options && options.index != null ? options.index : null);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return SubdocumentPath.prototype.doValidate.call(this, value, fn, scope, options);
|
|
87
|
+
};
|
|
78
88
|
this.$embeddedSchemaType.$isMongooseDocumentArrayElement = true;
|
|
79
89
|
this.$embeddedSchemaType.caster = this.Constructor;
|
|
80
90
|
this.$embeddedSchemaType.schema = this.schema;
|
package/lib/schema/number.js
CHANGED
|
@@ -164,8 +164,8 @@ SchemaNumber.checkRequired = SchemaType.checkRequired;
|
|
|
164
164
|
*/
|
|
165
165
|
|
|
166
166
|
SchemaNumber.prototype.checkRequired = function checkRequired(value, doc) {
|
|
167
|
-
if (SchemaType._isRef(this, value, doc, true)) {
|
|
168
|
-
return
|
|
167
|
+
if (typeof value === 'object' && SchemaType._isRef(this, value, doc, true)) {
|
|
168
|
+
return value != null;
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
// `require('util').inherits()` does **not** copy static properties, and
|
package/lib/schema/string.js
CHANGED
|
@@ -561,8 +561,8 @@ SchemaString.prototype.match = function match(regExp, message) {
|
|
|
561
561
|
*/
|
|
562
562
|
|
|
563
563
|
SchemaString.prototype.checkRequired = function checkRequired(value, doc) {
|
|
564
|
-
if (SchemaType._isRef(this, value, doc, true)) {
|
|
565
|
-
return
|
|
564
|
+
if (typeof value === 'object' && SchemaType._isRef(this, value, doc, true)) {
|
|
565
|
+
return value != null;
|
|
566
566
|
}
|
|
567
567
|
|
|
568
568
|
// `require('util').inherits()` does **not** copy static properties, and
|
package/lib/schema/symbols.js
CHANGED
package/lib/schema.js
CHANGED
|
@@ -107,11 +107,11 @@ function Schema(obj, options) {
|
|
|
107
107
|
this.inherits = {};
|
|
108
108
|
this.callQueue = [];
|
|
109
109
|
this._indexes = [];
|
|
110
|
-
this.methods = {};
|
|
110
|
+
this.methods = (options && options.methods) || {};
|
|
111
111
|
this.methodOptions = {};
|
|
112
|
-
this.statics = {};
|
|
112
|
+
this.statics = (options && options.statics) || {};
|
|
113
113
|
this.tree = {};
|
|
114
|
-
this.query = {};
|
|
114
|
+
this.query = (options && options.query) || {};
|
|
115
115
|
this.childSchemas = [];
|
|
116
116
|
this.plugins = [];
|
|
117
117
|
// For internal debugging. Do not use this to try to save a schema in MDB.
|
|
@@ -477,7 +477,7 @@ Schema.prototype.defaultOptions = function(options) {
|
|
|
477
477
|
* Inherit a Schema by applying a discriminator on an existing Schema.
|
|
478
478
|
*
|
|
479
479
|
*
|
|
480
|
-
* ####Example:
|
|
480
|
+
* #### Example:
|
|
481
481
|
*
|
|
482
482
|
* const options = { discriminatorKey: 'kind' };
|
|
483
483
|
*
|
|
@@ -648,7 +648,7 @@ Schema.prototype.add = function add(obj, prefix) {
|
|
|
648
648
|
* removeIndex only removes indexes from your schema object. Does **not** affect the indexes
|
|
649
649
|
* in MongoDB.
|
|
650
650
|
*
|
|
651
|
-
* ####Example:
|
|
651
|
+
* #### Example:
|
|
652
652
|
*
|
|
653
653
|
* const ToySchema = new Schema({ name: String, color: String, price: Number });
|
|
654
654
|
*
|
|
@@ -701,7 +701,7 @@ Schema.prototype.removeIndex = function removeIndex(index) {
|
|
|
701
701
|
* clearIndexes only removes indexes from your schema object. Does **not** affect the indexes
|
|
702
702
|
* in MongoDB.
|
|
703
703
|
*
|
|
704
|
-
* ####Example:
|
|
704
|
+
* #### Example:
|
|
705
705
|
*
|
|
706
706
|
* const ToySchema = new Schema({ name: String, color: String, price: Number });
|
|
707
707
|
* ToySchema.index({ name: 1 });
|
|
@@ -766,7 +766,6 @@ reserved['prototype'] =
|
|
|
766
766
|
// EventEmitter
|
|
767
767
|
reserved.emit =
|
|
768
768
|
reserved.listeners =
|
|
769
|
-
reserved.on =
|
|
770
769
|
reserved.removeListener =
|
|
771
770
|
|
|
772
771
|
// document properties and functions
|
package/lib/statemachine.js
CHANGED
|
@@ -95,6 +95,19 @@ StateMachine.prototype.clear = function clear(state) {
|
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
97
|
|
|
98
|
+
/*!
|
|
99
|
+
* ignore
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
StateMachine.prototype.clearPath = function clearPath(path) {
|
|
103
|
+
const state = this.paths[path];
|
|
104
|
+
if (!state) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
delete this.paths[path];
|
|
108
|
+
delete this.states[state][path];
|
|
109
|
+
};
|
|
110
|
+
|
|
98
111
|
/*!
|
|
99
112
|
* Checks to see if at least one path is in the states passed in via `arguments`
|
|
100
113
|
* e.g., this.some('required', 'inited')
|
package/lib/utils.js
CHANGED
package/lib/validoptions.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mongoose",
|
|
3
3
|
"description": "Mongoose MongoDB ODM",
|
|
4
|
-
"version": "6.
|
|
4
|
+
"version": "6.4.2",
|
|
5
5
|
"author": "Guillermo Rauch <guillermo@learnboost.com>",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"mongodb",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"bson": "^4.6.2",
|
|
23
|
-
"kareem": "2.
|
|
24
|
-
"mongodb": "4.
|
|
23
|
+
"kareem": "2.4.1",
|
|
24
|
+
"mongodb": "4.7.0",
|
|
25
25
|
"mpath": "0.9.0",
|
|
26
26
|
"mquery": "4.0.3",
|
|
27
27
|
"ms": "2.1.3",
|
package/tsconfig.json
CHANGED
package/types/collection.d.ts
CHANGED
package/types/connection.d.ts
CHANGED
|
@@ -66,6 +66,11 @@ declare module 'mongoose' {
|
|
|
66
66
|
close(callback: CallbackWithoutResult): void;
|
|
67
67
|
close(force?: boolean): Promise<void>;
|
|
68
68
|
|
|
69
|
+
/** Closes and destroys the connection. Connection once destroyed cannot be reopened */
|
|
70
|
+
destroy(force: boolean, callback: CallbackWithoutResult): void;
|
|
71
|
+
destroy(callback: CallbackWithoutResult): void;
|
|
72
|
+
destroy(force?: boolean): Promise<void>;
|
|
73
|
+
|
|
69
74
|
/** Retrieves a collection, creating it if not cached. */
|
|
70
75
|
collection<T extends AnyObject = AnyObject>(name: string, options?: mongodb.CreateCollectionOptions): Collection<T>;
|
|
71
76
|
|
package/types/document.d.ts
CHANGED
|
@@ -4,6 +4,12 @@ declare module 'mongoose' {
|
|
|
4
4
|
/** A list of paths to skip. If set, Mongoose will validate every modified path that is not in this list. */
|
|
5
5
|
type pathsToSkip = string[] | string;
|
|
6
6
|
|
|
7
|
+
interface DocumentSetOptions {
|
|
8
|
+
merge?: boolean;
|
|
9
|
+
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
}
|
|
12
|
+
|
|
7
13
|
/**
|
|
8
14
|
* Generic types for Document:
|
|
9
15
|
* * T - the type of _id
|
|
@@ -19,6 +25,9 @@ declare module 'mongoose' {
|
|
|
19
25
|
/** This documents __v. */
|
|
20
26
|
__v?: any;
|
|
21
27
|
|
|
28
|
+
/** Assert that a given path or paths is populated. Throws an error if not populated. */
|
|
29
|
+
$assertPopulated<Paths = {}>(paths: string | string[]): Omit<this, keyof Paths> & Paths;
|
|
30
|
+
|
|
22
31
|
/* Get all subdocs (by bfs) */
|
|
23
32
|
$getAllSubdocs(): Document[];
|
|
24
33
|
|
|
@@ -71,8 +80,8 @@ declare module 'mongoose' {
|
|
|
71
80
|
$session(session?: ClientSession | null): ClientSession | null;
|
|
72
81
|
|
|
73
82
|
/** Alias for `set()`, used internally to avoid conflicts */
|
|
74
|
-
$set(path: string, val: any, type: any, options?:
|
|
75
|
-
$set(path: string, val: any, options?:
|
|
83
|
+
$set(path: string, val: any, type: any, options?: DocumentSetOptions): this;
|
|
84
|
+
$set(path: string, val: any, options?: DocumentSetOptions): this;
|
|
76
85
|
$set(value: any): this;
|
|
77
86
|
|
|
78
87
|
/** Set this property to add additional query filters when Mongoose saves this document and `isNew` is false. */
|
|
@@ -191,10 +200,10 @@ declare module 'mongoose' {
|
|
|
191
200
|
$parent(): Document | undefined;
|
|
192
201
|
|
|
193
202
|
/** Populates document references. */
|
|
194
|
-
populate<Paths = {}>(path: string | PopulateOptions | (string | PopulateOptions)[]): Promise<this
|
|
195
|
-
populate<Paths = {}>(path: string | PopulateOptions | (string | PopulateOptions)[], callback: Callback<this
|
|
196
|
-
populate<Paths = {}>(path: string, select?: string | AnyObject, model?: Model<
|
|
197
|
-
populate<Paths = {}>(path: string, select?: string | AnyObject, model?: Model<
|
|
203
|
+
populate<Paths = {}>(path: string | PopulateOptions | (string | PopulateOptions)[]): Promise<MergeType<this, Paths>>;
|
|
204
|
+
populate<Paths = {}>(path: string | PopulateOptions | (string | PopulateOptions)[], callback: Callback<MergeType<this, Paths>>): void;
|
|
205
|
+
populate<Paths = {}>(path: string, select?: string | AnyObject, model?: Model<any>, match?: AnyObject, options?: PopulateOptions): Promise<MergeType<this, Paths>>;
|
|
206
|
+
populate<Paths = {}>(path: string, select?: string | AnyObject, model?: Model<any>, match?: AnyObject, options?: PopulateOptions, callback?: Callback<MergeType<this, Paths>>): void;
|
|
198
207
|
|
|
199
208
|
/** Gets _id(s) used during population of the given `path`. If the path was not populated, returns `undefined`. */
|
|
200
209
|
populated(path: string): any;
|