Comparing version 7.5.2 to 7.5.3
@@ -16,3 +16,4 @@ 'use strict'; | ||
'!.*', | ||
'node_modules' | ||
'node_modules', | ||
'.git' | ||
], | ||
@@ -19,0 +20,0 @@ overrides: [ |
@@ -312,4 +312,17 @@ 'use strict'; | ||
nested = val[$cond]; | ||
if ($cond === '$not') { | ||
if ($cond === '$elemMatch') { | ||
if (nested && schematype != null && schematype.schema != null) { | ||
cast(schematype.schema, nested, options, context); | ||
} else if (nested && schematype != null && schematype.$isMongooseArray) { | ||
if (utils.isPOJO(nested) && nested.$not != null) { | ||
cast(schema, nested, options, context); | ||
} else { | ||
val[$cond] = schematype.castForQuery( | ||
$cond, | ||
nested, | ||
context | ||
); | ||
} | ||
} | ||
} else if ($cond === '$not') { | ||
if (nested && schematype) { | ||
@@ -341,2 +354,3 @@ _keys = Object.keys(nested); | ||
} | ||
} | ||
@@ -343,0 +357,0 @@ } |
'use strict'; | ||
const assert = require('assert'); | ||
const { Long } = require('bson'); | ||
@@ -26,2 +27,6 @@ /** | ||
if (val instanceof Long) { | ||
return val.toBigInt(); | ||
} | ||
if (typeof val === 'string' || typeof val === 'number') { | ||
@@ -28,0 +33,0 @@ return BigInt(val); |
@@ -352,3 +352,3 @@ /*! | ||
client.s.options.hosts[0].port || void 0; | ||
conn.name = dbName != null ? dbName : client && client.s && client.s.options && client.s.options.dbName || void 0; | ||
conn.name = dbName != null ? dbName : db.databaseName; | ||
conn._closeCalled = client._closeCalled; | ||
@@ -355,0 +355,0 @@ |
@@ -10,11 +10,14 @@ 'use strict'; | ||
module.exports = function getConstructor(Constructor, value) { | ||
module.exports = function getConstructor(Constructor, value, defaultDiscriminatorValue) { | ||
const discriminatorKey = Constructor.schema.options.discriminatorKey; | ||
if (value != null && | ||
Constructor.discriminators && | ||
value[discriminatorKey] != null) { | ||
if (Constructor.discriminators[value[discriminatorKey]]) { | ||
Constructor = Constructor.discriminators[value[discriminatorKey]]; | ||
let discriminatorValue = (value != null && value[discriminatorKey]); | ||
if (discriminatorValue == null) { | ||
discriminatorValue = defaultDiscriminatorValue; | ||
} | ||
if (Constructor.discriminators && | ||
discriminatorValue != null) { | ||
if (Constructor.discriminators[discriminatorValue]) { | ||
Constructor = Constructor.discriminators[discriminatorValue]; | ||
} else { | ||
const constructorByValue = getDiscriminatorByValue(Constructor.discriminators, value[discriminatorKey]); | ||
const constructorByValue = getDiscriminatorByValue(Constructor.discriminators, discriminatorValue); | ||
if (constructorByValue) { | ||
@@ -21,0 +24,0 @@ Constructor = constructorByValue; |
@@ -23,2 +23,4 @@ 'use strict'; | ||
const now = originalModel.base.now(); | ||
const globalSetDefaultsOnInsert = originalModel.base.options.setDefaultsOnInsert; | ||
if (op['insertOne']) { | ||
@@ -73,3 +75,6 @@ return (callback) => { | ||
if (op['updateOne'].setDefaultsOnInsert !== false) { | ||
const shouldSetDefaultsOnInsert = op['updateOne'].setDefaultsOnInsert == null ? | ||
globalSetDefaultsOnInsert : | ||
op['updateOne'].setDefaultsOnInsert; | ||
if (shouldSetDefaultsOnInsert !== false) { | ||
setDefaultsOnInsert(op['updateOne']['filter'], model.schema, op['updateOne']['update'], { | ||
@@ -111,3 +116,7 @@ setDefaultsOnInsert: true, | ||
if (op['updateMany'].setDefaultsOnInsert !== false) { | ||
const shouldSetDefaultsOnInsert = op['updateMany'].setDefaultsOnInsert == null ? | ||
globalSetDefaultsOnInsert : | ||
op['updateMany'].setDefaultsOnInsert; | ||
if (shouldSetDefaultsOnInsert !== false) { | ||
setDefaultsOnInsert(op['updateMany']['filter'], model.schema, op['updateMany']['update'], { | ||
@@ -114,0 +123,0 @@ setDefaultsOnInsert: true, |
@@ -164,3 +164,5 @@ 'use strict'; | ||
const Constructor = getConstructor(this.caster, val); | ||
const discriminatorKeyPath = this.schema.path(this.schema.options.discriminatorKey); | ||
const defaultDiscriminatorValue = discriminatorKeyPath == null ? null : discriminatorKeyPath.getDefault(doc); | ||
const Constructor = getConstructor(this.caster, val, defaultDiscriminatorValue); | ||
@@ -167,0 +169,0 @@ let subdoc; |
{ | ||
"name": "mongoose", | ||
"description": "Mongoose MongoDB ODM", | ||
"version": "7.5.2", | ||
"version": "7.5.3", | ||
"author": "Guillermo Rauch <guillermo@learnboost.com>", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
@@ -233,3 +233,3 @@ /// <reference path="./aggregate.d.ts" /> | ||
>, | ||
THydratedDocumentType = HydratedDocument<DocType, TVirtuals & TInstanceMethods> | ||
THydratedDocumentType = HydratedDocument<FlatRecord<DocType>, TVirtuals & TInstanceMethods> | ||
> | ||
@@ -240,3 +240,3 @@ extends events.EventEmitter { | ||
*/ | ||
constructor(definition?: SchemaDefinition<SchemaDefinitionType<EnforcedDocType>, EnforcedDocType> | DocType, options?: SchemaOptions<DocType, TInstanceMethods, TQueryHelpers, TStaticMethods, TVirtuals, THydratedDocumentType> | ResolveSchemaOptions<TSchemaOptions>); | ||
constructor(definition?: SchemaDefinition<SchemaDefinitionType<EnforcedDocType>, EnforcedDocType> | DocType, options?: SchemaOptions<FlatRecord<DocType>, TInstanceMethods, TQueryHelpers, TStaticMethods, TVirtuals, THydratedDocumentType> | ResolveSchemaOptions<TSchemaOptions>); | ||
@@ -243,0 +243,0 @@ /** Adds key path / schema type pairs to this schema. */ |
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
2662260
50057