Skip to content

Commit

Permalink
Merge branch '2.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Juan Carlos Muñoz committed Jul 9, 2019
2 parents b0ecf76 + 473742f commit a94dcd7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ module.exports = function(schema, options) {
const parentDoc = isSubdocument ? this.ownerDocument() : this;
const isNew = typeof parentDoc.isNew === "boolean" ? parentDoc.isNew : !isQuery;

const conditions = indexOptions.partialFilterExpression || {};
let conditions = {};
each(paths, name => {
let pathValue;

Expand Down Expand Up @@ -113,6 +113,7 @@ module.exports = function(schema, options) {
if (model.baseModelName && indexOptions.partialFilterExpression === null) {
model = model.db.model(model.baseModelName);
}
conditions = {$and: [conditions, indexOptions.partialFilterExpression || {}]};

model.find(conditions).countDocuments((err, count) => {
resolve(count === 0);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mongoose-unique-validator",
"version": "2.1.0",
"version": "2.1.1",
"description": "mongoose-unique-validator is a plugin which adds pre-save validation for unique fields within a Mongoose schema.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit a94dcd7

Please sign in to comment.