Comparing version 8.8.0 to 8.8.1
@@ -10,4 +10,3 @@ 'use strict'; | ||
return ( | ||
typeof obj === 'object' && | ||
obj !== null && | ||
obj != null && | ||
obj._bsontype === typename | ||
@@ -14,0 +13,0 @@ ); |
@@ -248,3 +248,3 @@ 'use strict'; | ||
if (op !== '$setOnInsert' && | ||
handleImmutable(schematype, strict, obj, key, prefix + key, context)) { | ||
handleImmutable(schematype, strict, obj, key, prefix + key, options, context)) { | ||
continue; | ||
@@ -357,3 +357,3 @@ } | ||
if (op !== '$setOnInsert' && | ||
handleImmutable(schematype, strict, obj, key, prefix + key, context)) { | ||
handleImmutable(schematype, strict, obj, key, prefix + key, options, context)) { | ||
continue; | ||
@@ -360,0 +360,0 @@ } |
@@ -5,3 +5,16 @@ 'use strict'; | ||
module.exports = function handleImmutable(schematype, strict, obj, key, fullPath, ctx) { | ||
/** | ||
* Handle immutable option for a given path when casting updates based on options | ||
* | ||
* @param {SchemaType} schematype the resolved schematype for this path | ||
* @param {Boolean | 'throw' | null} strict whether strict mode is set for this query | ||
* @param {Object} obj the object containing the value being checked so we can delete | ||
* @param {String} key the key in `obj` which we are checking for immutability | ||
* @param {String} fullPath the full path being checked | ||
* @param {Object} options the query options | ||
* @param {Query} ctx the query. Passed as `this` and first param to the `immutable` option, if `immutable` is a function | ||
* @returns true if field was removed, false otherwise | ||
*/ | ||
module.exports = function handleImmutable(schematype, strict, obj, key, fullPath, options, ctx) { | ||
if (schematype == null || !schematype.options || !schematype.options.immutable) { | ||
@@ -19,2 +32,5 @@ return false; | ||
if (options && options.overwriteImmutable) { | ||
return false; | ||
} | ||
if (strict === false) { | ||
@@ -21,0 +37,0 @@ return false; |
'use strict'; | ||
const get = require('../get'); | ||
module.exports = function applyReadConcern(schema, options) { | ||
@@ -18,3 +16,3 @@ if (options.readConcern !== undefined) { | ||
const level = get(schema, 'options.readConcern.level', null); | ||
const level = schema.options?.readConcern?.level; | ||
if (level != null) { | ||
@@ -21,0 +19,0 @@ options.readConcern = { level }; |
'use strict'; | ||
const get = require('../get'); | ||
module.exports = function applyWriteConcern(schema, options) { | ||
@@ -15,3 +13,3 @@ if (options.writeConcern != null) { | ||
} | ||
const writeConcern = get(schema, 'options.writeConcern', {}); | ||
const writeConcern = schema.options.writeConcern ?? {}; | ||
if (Object.keys(writeConcern).length != 0) { | ||
@@ -18,0 +16,0 @@ options.writeConcern = {}; |
@@ -664,2 +664,4 @@ 'use strict'; | ||
applyEmbeddedDiscriminators(schema); | ||
const connection = options.connection || _mongoose.connection; | ||
@@ -682,4 +684,2 @@ model = _mongoose.Model.compile(model || name, schema, collection, connection, _mongoose); | ||
applyEmbeddedDiscriminators(schema); | ||
return model; | ||
@@ -686,0 +686,0 @@ }; |
{ | ||
"name": "mongoose", | ||
"description": "Mongoose MongoDB ODM", | ||
"version": "8.8.0", | ||
"version": "8.8.1", | ||
"author": "Guillermo Rauch <guillermo@learnboost.com>", | ||
@@ -31,4 +31,4 @@ "keywords": [ | ||
"devDependencies": { | ||
"@babel/core": "7.24.7", | ||
"@babel/preset-env": "7.25.4", | ||
"@babel/core": "7.26.0", | ||
"@babel/preset-env": "7.26.0", | ||
"@typescript-eslint/eslint-plugin": "^8.4.0", | ||
@@ -45,3 +45,3 @@ "@typescript-eslint/parser": "^8.4.0", | ||
"cheerio": "1.0.0", | ||
"crypto-browserify": "3.12.0", | ||
"crypto-browserify": "3.12.1", | ||
"dotenv": "16.4.5", | ||
@@ -58,7 +58,7 @@ "dox": "1.0.0", | ||
"markdownlint-cli2": "^0.14.0", | ||
"marked": "14.1.2", | ||
"marked": "14.1.3", | ||
"mkdirp": "^3.0.1", | ||
"mocha": "10.7.3", | ||
"mocha": "10.8.2", | ||
"moment": "2.30.1", | ||
"mongodb-memory-server": "10.0.1", | ||
"mongodb-memory-server": "10.1.2", | ||
"ncp": "^2.0.0", | ||
@@ -71,5 +71,5 @@ "nyc": "15.1.0", | ||
"tsd": "0.31.2", | ||
"typescript": "5.6.2", | ||
"uuid": "10.0.0", | ||
"webpack": "5.95.0" | ||
"typescript": "5.6.3", | ||
"uuid": "11.0.2", | ||
"webpack": "5.96.1" | ||
}, | ||
@@ -76,0 +76,0 @@ "directories": { |
@@ -23,2 +23,3 @@ declare module 'mongoose' { | ||
| 'overwriteDiscriminatorKey' | ||
| 'overwriteImmutable' | ||
| 'populate' | ||
@@ -158,2 +159,7 @@ | 'runValidators' | ||
overwriteDiscriminatorKey?: boolean; | ||
/** | ||
* Mongoose removes updated immutable properties from `update` by default (excluding $setOnInsert). | ||
* Set `overwriteImmutable` to `true` to allow updating immutable properties using other update operators. | ||
*/ | ||
overwriteImmutable?: boolean; | ||
projection?: ProjectionType<DocType>; | ||
@@ -160,0 +166,0 @@ /** |
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
2750151
52061
1
66
10