Comparing version 8.5.1 to 8.5.2
@@ -20,3 +20,3 @@ 'use strict'; | ||
* | ||
* Functions are never cloned. | ||
* Functions and primitives are never cloned. | ||
* | ||
@@ -34,2 +34,5 @@ * @param {Object} obj the object to clone | ||
} | ||
if (typeof obj === 'number' || typeof obj === 'string' || typeof obj === 'boolean' || typeof obj === 'bigint') { | ||
return obj; | ||
} | ||
@@ -153,9 +156,8 @@ if (Array.isArray(obj)) { | ||
let i = 0; | ||
let key = ''; | ||
const keys = Object.keys(obj); | ||
const len = keys.length; | ||
for (i = 0; i < len; ++i) { | ||
if (specialProperties.has(key = keys[i])) { | ||
for (let i = 0; i < len; ++i) { | ||
const key = keys[i]; | ||
if (specialProperties.has(key)) { | ||
continue; | ||
@@ -162,0 +164,0 @@ } |
@@ -96,4 +96,8 @@ 'use strict'; | ||
} else if (val.$switch != null) { | ||
val.branches.map(v => _castExpression(v, schema, strictQuery)); | ||
val.default = _castExpression(val.default, schema, strictQuery); | ||
if (Array.isArray(val.$switch.branches)) { | ||
val.$switch.branches = val.$switch.branches.map(v => _castExpression(v, schema, strictQuery)); | ||
} | ||
if ('default' in val.$switch) { | ||
val.$switch.default = _castExpression(val.$switch.default, schema, strictQuery); | ||
} | ||
} | ||
@@ -100,0 +104,0 @@ |
@@ -72,3 +72,3 @@ 'use strict'; | ||
if (!('defaultValue' in this) || fn !== void 0) { | ||
if (!('defaultValue' in this) || fn != null) { | ||
this.default(function() { | ||
@@ -75,0 +75,0 @@ let arr = fn.call(this); |
@@ -1545,3 +1545,3 @@ 'use strict'; | ||
if (value.$__ != null) { | ||
value.$__.wasPopulated = value.$__.wasPopulated || { value: value._id }; | ||
value.$__.wasPopulated = value.$__.wasPopulated || { value: value._doc._id }; | ||
return value; | ||
@@ -1572,3 +1572,3 @@ } | ||
ret = new pop.options[populateModelSymbol](value); | ||
ret.$__.wasPopulated = { value: ret._id }; | ||
ret.$__.wasPopulated = { value: ret._doc._id }; | ||
} | ||
@@ -1575,0 +1575,0 @@ |
@@ -119,3 +119,3 @@ 'use strict'; | ||
// Doesn't support single nested "in-place" populate | ||
v.$__.wasPopulated = { value: v._id }; | ||
v.$__.wasPopulated = { value: v._doc._id }; | ||
return v; | ||
@@ -128,3 +128,3 @@ }); | ||
// Doesn't support single nested "in-place" populate | ||
value.$__.wasPopulated = { value: value._id }; | ||
value.$__.wasPopulated = { value: value._doc._id }; | ||
} | ||
@@ -131,0 +131,0 @@ } else { |
{ | ||
"name": "mongoose", | ||
"description": "Mongoose MongoDB ODM", | ||
"version": "8.5.1", | ||
"version": "8.5.2", | ||
"author": "Guillermo Rauch <guillermo@learnboost.com>", | ||
@@ -60,3 +60,3 @@ "keywords": [ | ||
"moment": "2.30.1", | ||
"mongodb-memory-server": "9.4.0", | ||
"mongodb-memory-server": "10.0.0", | ||
"ncp": "^2.0.0", | ||
@@ -63,0 +63,0 @@ "nyc": "15.1.0", |
@@ -223,3 +223,4 @@ declare module 'mongoose' { | ||
/** Cast `val` to this schema type. Each class that inherits from schema type should implement this function. */ | ||
cast(val: any, doc: Document<any>, init: boolean, prev?: any, options?: any): any; | ||
cast(val: any, doc?: Document<any>, init?: boolean, prev?: any, options?: any): any; | ||
cast<ResultType>(val: any, doc?: Document<any>, init?: boolean, prev?: any, options?: any): ResultType; | ||
@@ -447,3 +448,3 @@ /** Sets a default value for this SchemaType. */ | ||
class Subdocument extends SchemaType implements AcceptsDiscriminator { | ||
class Subdocument<DocType = unknown> extends SchemaType implements AcceptsDiscriminator { | ||
/** This schema type's name, to defend against minifiers that mangle function names. */ | ||
@@ -460,2 +461,4 @@ static schemaName: string; | ||
discriminator<D>(name: string | number, schema: Schema, value?: string): Model<D>; | ||
cast(val: any, doc?: Document<any>, init?: boolean, prev?: any, options?: any): HydratedSingleSubdocument<DocType>; | ||
} | ||
@@ -462,0 +465,0 @@ |
Sorry, the diff of this file is too big to display
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
2709285
51079