diff --git a/index.js b/index.js index b10acfb..38cfc1a 100644 --- a/index.js +++ b/index.js @@ -116,7 +116,7 @@ module.exports = function (schema, options) { if (model.baseModelName && indexOptions.partialFilterExpression === null) { model = model.db.model(model.baseModelName); } - conditions = {$and: [conditions, indexOptions.partialFilterExpression || {}]}; + conditions = {...indexOptions.partialFilterExpression, ...conditions}; const count = await model.find(conditions).countDocuments(); return count === 0; diff --git a/package.json b/package.json index 9c021d6..680d510 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mongoose-unique-validator", - "version": "3.0.0", + "version": "3.0.1", "description": "mongoose-unique-validator is a plugin which adds pre-save validation for unique fields within a Mongoose schema.", "main": "index.js", "scripts": {