Comparing version 7.6.2 to 7.6.3
@@ -9,2 +9,3 @@ 'use strict'; | ||
const castUpdate = require('../query/castUpdate'); | ||
const decorateUpdateWithVersionKey = require('../update/decorateUpdateWithVersionKey'); | ||
const { inspect } = require('util'); | ||
@@ -37,2 +38,6 @@ const setDefaultsOnInsert = require('../setDefaultsOnInsert'); | ||
} | ||
const versionKey = model?.schema?.options?.versionKey; | ||
if (versionKey && doc[versionKey] == null) { | ||
doc[versionKey] = 0; | ||
} | ||
op['insertOne']['document'] = doc; | ||
@@ -86,2 +91,8 @@ | ||
decorateUpdateWithVersionKey( | ||
op['updateOne']['update'], | ||
op['updateOne'], | ||
model.schema.options.versionKey | ||
); | ||
op['updateOne']['filter'] = cast(model.schema, op['updateOne']['filter'], { | ||
@@ -139,2 +150,8 @@ strict: strict, | ||
decorateUpdateWithVersionKey( | ||
op['updateMany']['update'], | ||
op['updateMany'], | ||
model.schema.options.versionKey | ||
); | ||
op['updateMany']['filter'] = cast(model.schema, op['updateMany']['filter'], { | ||
@@ -180,2 +197,6 @@ strict: strict, | ||
} | ||
const versionKey = model?.schema?.options?.versionKey; | ||
if (versionKey && doc[versionKey] == null) { | ||
doc[versionKey] = 0; | ||
} | ||
op['replaceOne']['replacement'] = doc; | ||
@@ -182,0 +203,0 @@ |
@@ -129,3 +129,4 @@ 'use strict'; | ||
// https://github.com/mongodb/node-mongodb-native/pull/2490 | ||
return { $setOnInsert: filter }; | ||
// Shallow clone to avoid passing defaults in re: gh-13962 | ||
return { $setOnInsert: { ...filter } }; | ||
} | ||
@@ -132,0 +133,0 @@ return ret; |
@@ -34,2 +34,5 @@ 'use strict'; | ||
const oneSpaceRE = /\s/; | ||
const manySpaceRE = /\s+/; | ||
/** | ||
@@ -576,4 +579,4 @@ * Produces a collection name from model `name`. By default, just returns | ||
arr.forEach(function(obj) { | ||
if (/[\s]/.test(obj.path)) { | ||
const paths = obj.path.split(' '); | ||
if (oneSpaceRE.test(obj.path)) { | ||
const paths = obj.path.split(manySpaceRE); | ||
paths.forEach(function(p) { | ||
@@ -597,5 +600,5 @@ const copy = Object.assign({}, obj); | ||
obj.populate.forEach(function(obj) { | ||
if (/[\s]/.test(obj.path)) { | ||
if (oneSpaceRE.test(obj.path)) { | ||
const copy = Object.assign({}, obj); | ||
const paths = copy.path.split(' '); | ||
const paths = copy.path.split(manySpaceRE); | ||
paths.forEach(function(p) { | ||
@@ -615,3 +618,3 @@ copy.path = p; | ||
const ret = []; | ||
const paths = obj.path.split(' '); | ||
const paths = oneSpaceRE.test(obj.path) ? obj.path.split(manySpaceRE) : [obj.path]; | ||
if (obj.options != null) { | ||
@@ -618,0 +621,0 @@ obj.options = clone(obj.options); |
{ | ||
"name": "mongoose", | ||
"description": "Mongoose MongoDB ODM", | ||
"version": "7.6.2", | ||
"version": "7.6.3", | ||
"author": "Guillermo Rauch <guillermo@learnboost.com>", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
@@ -263,3 +263,3 @@ /// <reference path="./aggregate.d.ts" /> | ||
discriminator<DisSchema = Schema>(name: string, schema: DisSchema): this; | ||
discriminator<DisSchema = Schema>(name: string | number, schema: DisSchema): this; | ||
@@ -266,0 +266,0 @@ /** Returns a new schema that has the picked `paths` from this schema. */ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2649447
280
49498