mongoose 6.4.0 → 6.4.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/.eslintrc.json +5 -2
- 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/document.js +8 -2
- 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 +1 -1
- 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/index.js +2 -2
- 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/queryhelpers.js +5 -0
- package/lib/schema/array.js +1 -1
- package/lib/schema/date.js +2 -2
- 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 +3 -3
- package/lib/schematype.js +2 -1
- package/lib/types/DocumentArray/methods/index.js +1 -1
- package/lib/types/buffer.js +26 -28
- package/lib/types/decimal128.js +3 -3
- package/lib/types/map.js +70 -0
- package/package.json +11 -11
- package/types/collection.d.ts +1 -1
- package/types/document.d.ts +12 -6
- package/types/expressions.d.ts +30 -9
- package/types/index.d.ts +13 -12
- package/types/{indizes.d.ts → indexes.d.ts} +2 -2
- package/types/inferschematype.d.ts +51 -33
- package/types/middlewares.d.ts +1 -1
- package/types/models.d.ts +14 -14
- package/types/mongooseoptions.d.ts +1 -1
- package/types/pipelinestage.d.ts +2 -2
- package/types/query.d.ts +1 -1
- package/types/schemaoptions.d.ts +1 -1
- package/types/types.d.ts +3 -1
- package/types/utility.d.ts +8 -1
package/lib/cast/date.js
CHANGED
package/lib/cast/decimal128.js
CHANGED
package/lib/cast/objectid.js
CHANGED
package/lib/cast.js
CHANGED
package/lib/document.js
CHANGED
|
@@ -1035,6 +1035,7 @@ Document.prototype.overwrite = function overwrite(obj) {
|
|
|
1035
1035
|
* @param {Any} val the value to set
|
|
1036
1036
|
* @param {Schema|String|Number|Buffer|*} [type] optionally specify a type for "on-the-fly" attributes
|
|
1037
1037
|
* @param {Object} [options] optionally specify options that modify the behavior of the set
|
|
1038
|
+
* @param {Boolean} [options.merge=false] if true, setting a [nested path](/docs/subdocs.html#subdocuments-versus-nested-paths) will merge existing values rather than overwrite the whole object. So `doc.set('nested', { a: 1, b: 2 })` becomes `doc.set('nested.a', 1); doc.set('nested.b', 2);`
|
|
1038
1039
|
* @method $set
|
|
1039
1040
|
* @name $set
|
|
1040
1041
|
* @memberOf Document
|
|
@@ -1408,7 +1409,11 @@ Document.prototype.$set = function $set(path, val, type, options) {
|
|
|
1408
1409
|
// later in `$__set()` because we don't take `_doc` when we iterate through
|
|
1409
1410
|
// a single nested doc. That's to make sure we get the correct context.
|
|
1410
1411
|
// Otherwise we would double-call the setter, see gh-7196.
|
|
1411
|
-
|
|
1412
|
+
if (options != null && options.overwriteImmutable) {
|
|
1413
|
+
val = schema.applySetters(val, this, false, priorVal, { overwriteImmutable: true });
|
|
1414
|
+
} else {
|
|
1415
|
+
val = schema.applySetters(val, this, false, priorVal);
|
|
1416
|
+
}
|
|
1412
1417
|
}
|
|
1413
1418
|
|
|
1414
1419
|
if (Array.isArray(val) &&
|
|
@@ -4337,9 +4342,10 @@ Document.prototype.$populated = Document.prototype.populated;
|
|
|
4337
4342
|
* doc.$assertPopulated('other path'); // throws an error
|
|
4338
4343
|
*
|
|
4339
4344
|
*
|
|
4340
|
-
* @param {String
|
|
4345
|
+
* @param {String|Array<String>} path
|
|
4341
4346
|
* @return {Document} this
|
|
4342
4347
|
* @memberOf Document
|
|
4348
|
+
* @method $assertPopulated
|
|
4343
4349
|
* @instance
|
|
4344
4350
|
* @api public
|
|
4345
4351
|
*/
|
|
@@ -9,4 +9,4 @@ exports.Collection = require('./collection');
|
|
|
9
9
|
exports.Decimal128 = require('./decimal128');
|
|
10
10
|
exports.ObjectId = require('./objectid');
|
|
11
11
|
exports.ReadPreference = require('./ReadPreference');
|
|
12
|
-
exports.getConnection = () => require('./connection');
|
|
12
|
+
exports.getConnection = () => require('./connection');
|
package/lib/helpers/each.js
CHANGED
package/lib/helpers/get.js
CHANGED
package/lib/helpers/isObject.js
CHANGED
package/lib/helpers/isPromise.js
CHANGED
package/lib/helpers/once.js
CHANGED
package/lib/helpers/pluralize.js
CHANGED
|
@@ -14,4 +14,4 @@ if (typeof jest !== 'undefined' && process.nextTick.toString().indexOf('nextTick
|
|
|
14
14
|
'with Jest\'s mock timers enabled. Please make sure you read ' +
|
|
15
15
|
'Mongoose\'s docs on configuring Jest to test Node.js apps: ' +
|
|
16
16
|
'https://mongoosejs.com/docs/jest.html');
|
|
17
|
-
}
|
|
17
|
+
}
|
|
@@ -9,7 +9,7 @@ function processConnectionOptions(uri, options) {
|
|
|
9
9
|
? opts.readPreference
|
|
10
10
|
: getUriReadPreference(uri);
|
|
11
11
|
|
|
12
|
-
const resolvedOpts = (readPreference && readPreference !== 'primary')
|
|
12
|
+
const resolvedOpts = (readPreference && readPreference !== 'primary' && readPreference !== 'primaryPreferred')
|
|
13
13
|
? resolveOptsConflicts(readPreference, opts)
|
|
14
14
|
: opts;
|
|
15
15
|
|
package/lib/helpers/symbols.js
CHANGED
|
@@ -17,4 +17,4 @@ exports.populateModelSymbol = Symbol('mongoose.PopulateOptions#Model');
|
|
|
17
17
|
exports.schemaTypeSymbol = Symbol('mongoose#schemaType');
|
|
18
18
|
exports.sessionNewDocuments = Symbol('mongoose:ClientSession#newDocuments');
|
|
19
19
|
exports.scopeSymbol = Symbol('mongoose#Document#scope');
|
|
20
|
-
exports.validatorErrorSymbol = Symbol('mongoose:validatorError');
|
|
20
|
+
exports.validatorErrorSymbol = Symbol('mongoose:validatorError');
|
package/lib/helpers/timers.js
CHANGED
|
@@ -13,4 +13,4 @@ module.exports = function isSSLError(topologyDescription) {
|
|
|
13
13
|
const descriptions = Array.from(topologyDescription.servers.values());
|
|
14
14
|
return descriptions.length > 0 &&
|
|
15
15
|
descriptions.every(descr => descr.error && descr.error.message.indexOf(nonSSLMessage) !== -1);
|
|
16
|
-
};
|
|
16
|
+
};
|
package/lib/index.js
CHANGED
|
@@ -1223,7 +1223,7 @@ Mongoose.prototype._promiseOrCallback = function(callback, fn, ee) {
|
|
|
1223
1223
|
/**
|
|
1224
1224
|
* Use this function in `pre()` middleware to skip calling the wrapped function.
|
|
1225
1225
|
*
|
|
1226
|
-
* ####Example:
|
|
1226
|
+
* #### Example:
|
|
1227
1227
|
*
|
|
1228
1228
|
* schema.pre('save', function() {
|
|
1229
1229
|
* // Will skip executing `save()`, but will execute post hooks as if
|
|
@@ -1241,7 +1241,7 @@ Mongoose.prototype.skipMiddlewareFunction = Kareem.skipWrappedFunction;
|
|
|
1241
1241
|
/**
|
|
1242
1242
|
* Use this function in `post()` middleware to replace the result
|
|
1243
1243
|
*
|
|
1244
|
-
* ####Example:
|
|
1244
|
+
* #### Example:
|
|
1245
1245
|
*
|
|
1246
1246
|
* schema.post('find', function(res) {
|
|
1247
1247
|
* // Normally you have to modify `res` in place. But with
|