Comparing version
@@ -147,3 +147,20 @@ 'use strict'; | ||
} | ||
mpath.set(_path, valueToSet, docs[i], void 0, setValue, false); | ||
mpath.set( | ||
_path, | ||
valueToSet, | ||
docs[i], | ||
// Handle setting paths underneath maps using $* by converting arrays into maps of values | ||
function lookup(obj, part, val) { | ||
if (arguments.length >= 3) { | ||
obj[part] = val; | ||
return obj[part]; | ||
} | ||
if (obj instanceof Map && part === '$*') { | ||
return [...obj.values()]; | ||
} | ||
return obj[part]; | ||
}, | ||
setValue, | ||
false | ||
); | ||
continue; | ||
@@ -150,0 +167,0 @@ } |
@@ -61,2 +61,33 @@ 'use strict'; | ||
continue; | ||
} else if (schema.paths[cur]?.$isSchemaMap && schema.paths[cur].$__schemaType?.schema) { | ||
schema = schema.paths[cur].$__schemaType.schema; | ||
++i; | ||
const rest = parts.slice(i + 1).join('.'); | ||
if (schema.virtuals[rest]) { | ||
if (i === parts.length - 2) { | ||
return { | ||
virtual: schema.virtuals[rest], | ||
nestedSchemaPath: [nestedSchemaPath, cur, '$*'].filter(v => !!v).join('.') | ||
}; | ||
} | ||
continue; | ||
} | ||
if (i + 1 < parts.length && schema.discriminators) { | ||
for (const key of Object.keys(schema.discriminators)) { | ||
const res = getVirtual(schema.discriminators[key], rest); | ||
if (res != null) { | ||
const _path = [nestedSchemaPath, cur, res.nestedSchemaPath, '$*']. | ||
filter(v => !!v).join('.'); | ||
return { | ||
virtual: res.virtual, | ||
nestedSchemaPath: _path | ||
}; | ||
} | ||
} | ||
} | ||
nestedSchemaPath += (nestedSchemaPath.length > 0 ? '.' : '') + '$*' + cur; | ||
cur = ''; | ||
} | ||
@@ -63,0 +94,0 @@ |
@@ -150,2 +150,5 @@ 'use strict'; | ||
} | ||
if (schemaPath.$isSingleNested) { | ||
alreadyValidated.push(updates[i]); | ||
} | ||
@@ -250,2 +253,1 @@ schemaPath.doValidate(v, function(err) { | ||
}; | ||
@@ -7,3 +7,2 @@ /*! | ||
const Document = require('../../document'); | ||
const mongooseArrayMethods = require('./methods'); | ||
@@ -77,7 +76,3 @@ | ||
// Because doc comes from the context of another function, doc === global | ||
// can happen if there was a null somewhere up the chain (see #3020) | ||
// RB Jun 17, 2015 updated to check for presence of expected paths instead | ||
// to make more proof against unusual node environments | ||
if (doc != null && doc instanceof Document) { | ||
if (doc != null && doc.$__) { | ||
internals[arrayParentSymbol] = doc; | ||
@@ -84,0 +79,0 @@ internals[arraySchemaSymbol] = schematype || doc.schema.path(path); |
@@ -9,3 +9,2 @@ 'use strict'; | ||
const DocumentArrayMethods = require('./methods'); | ||
const Document = require('../../document'); | ||
@@ -55,7 +54,3 @@ const arrayAtomicsSymbol = require('../../helpers/symbols').arrayAtomicsSymbol; | ||
// Because doc comes from the context of another function, doc === global | ||
// can happen if there was a null somewhere up the chain (see #3020 && #3034) | ||
// RB Jun 17, 2015 updated to check for presence of expected paths instead | ||
// to make more proof against unusual node environments | ||
if (doc && doc instanceof Document) { | ||
if (doc && doc.$__) { | ||
internals[arrayParentSymbol] = doc; | ||
@@ -62,0 +57,0 @@ internals[arraySchemaSymbol] = doc.$__schema.path(path); |
{ | ||
"name": "mongoose", | ||
"description": "Mongoose MongoDB ODM", | ||
"version": "8.15.1", | ||
"version": "8.15.2", | ||
"author": "Guillermo Rauch <guillermo@learnboost.com>", | ||
@@ -32,8 +32,8 @@ "keywords": [ | ||
"devDependencies": { | ||
"@babel/core": "7.27.1", | ||
"@babel/preset-env": "7.27.1", | ||
"@babel/core": "7.27.4", | ||
"@babel/preset-env": "7.27.2", | ||
"@mongodb-js/mongodb-downloader": "^0.3.9", | ||
"@typescript-eslint/eslint-plugin": "^8.19.1", | ||
"@typescript-eslint/parser": "^8.19.1", | ||
"acquit": "1.3.0", | ||
"acquit": "1.4.0", | ||
"acquit-ignore": "0.2.1", | ||
@@ -57,6 +57,6 @@ "acquit-require": "0.1.1", | ||
"lodash.isequalwith": "4.4.0", | ||
"markdownlint-cli2": "^0.17.1", | ||
"marked": "15.0.11", | ||
"markdownlint-cli2": "^0.18.1", | ||
"marked": "15.0.12", | ||
"mkdirp": "^3.0.1", | ||
"mocha": "11.2.2", | ||
"mocha": "11.5.0", | ||
"moment": "2.30.1", | ||
@@ -74,3 +74,3 @@ "mongodb-memory-server": "10.1.4", | ||
"uuid": "11.1.0", | ||
"webpack": "5.99.7" | ||
"webpack": "5.99.9" | ||
}, | ||
@@ -108,2 +108,3 @@ "directories": { | ||
"publish-7x": "npm publish --tag 7x", | ||
"create-separate-require-instance": "rm -rf ./node_modules/mongoose-separate-require-instance && node ./scripts/create-tarball && tar -xzf mongoose.tgz -C ./node_modules && mv ./node_modules/package ./node_modules/mongoose-separate-require-instance", | ||
"test": "mocha --exit ./test/*.test.js", | ||
@@ -110,0 +111,0 @@ "test-deno": "deno run --allow-env --allow-read --allow-net --allow-run --allow-sys --allow-write ./test/deno.mjs", |
@@ -328,3 +328,3 @@ # Mongoose | ||
Find the API docs [here](http://mongoosejs.com/docs/api/mongoose.html), generated using [dox](https://github.com/tj/dox) | ||
[Mongoose API documentation](http://mongoosejs.com/docs/api/mongoose.html), generated using [dox](https://github.com/tj/dox) | ||
and [acquit](https://github.com/vkarpov15/acquit). | ||
@@ -331,0 +331,0 @@ |
@@ -485,3 +485,3 @@ declare module 'mongoose' { | ||
*/ | ||
hydrate(obj: any, projection?: AnyObject, options?: HydrateOptions): THydratedDocumentType; | ||
hydrate(obj: any, projection?: ProjectionType<TRawDocType>, options?: HydrateOptions): THydratedDocumentType; | ||
@@ -488,0 +488,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
Sorry, the diff of this file is too big to display
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
54599
0.13%2568734
-11.2%