mongoose-unique-validator
Advanced tools
Comparing version 3.0.0 to 3.1.0
# Changelog | ||
## 3.1.0 | ||
- Fixes "expected _id to be unique" errors. | ||
- Fixes error when `model` is the name of a field. | ||
## 3.0.0 | ||
@@ -4,0 +9,0 @@ |
13
index.js
@@ -61,2 +61,7 @@ 'use strict'; | ||
const conditions = {}; | ||
if (!isNew && !isQuery && !parentDoc.isModified(pathName)) { | ||
return resolve(true); | ||
} | ||
each(paths, (name) => { | ||
@@ -107,2 +112,4 @@ let pathValue; | ||
model = this.model(this.constructor.modelName); | ||
} else { | ||
model = this.constructor.model(this.constructor.modelName); | ||
} | ||
@@ -113,3 +120,4 @@ | ||
// https://github.com/Automattic/mongoose/issues/4965 | ||
if (model.baseModelName && indexOptions.partialFilterExpression === null) { | ||
// eslint-disable-next-line | ||
if (model.baseModelName && (indexOptions.partialFilterExpression === null || indexOptions.partialFilterExpression === undefined)) { | ||
model = model.db.model(model.baseModelName); | ||
@@ -129,6 +137,5 @@ } | ||
plugin.defaults = { | ||
}; | ||
plugin.defaults = {}; | ||
// Export the mongoose plugin | ||
module.exports = plugin; |
{ | ||
"name": "mongoose-unique-validator", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "mongoose-unique-validator is a plugin which adds pre-save validation for unique fields within a Mongoose schema.", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "mocha test --exit && ./node_modules/eslint/bin/eslint.js index.js test", | ||
"test": "mocha test --exit", | ||
"lint": "eslint index.js test" | ||
@@ -34,4 +34,4 @@ }, | ||
"chai": "^4.3.4", | ||
"eslint": "^7.32.0", | ||
"mocha": "^9.1.2", | ||
"eslint": "^8.16.0", | ||
"mocha": "^10.0.0", | ||
"mongoose": "^6.0.0" | ||
@@ -38,0 +38,0 @@ }, |
Sorry, the diff of this file is not supported yet
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
111
64373