From 9ec88f55a71f20f8cd676affc2b92d90c86f91e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Carlos=20Mu=C3=B1oz?= Date: Tue, 14 May 2024 12:45:16 -0400 Subject: [PATCH] back to last conditions --- index.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 38cfc1a..b10acfb 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 = {...indexOptions.partialFilterExpression, ...conditions}; + conditions = {$and: [conditions, indexOptions.partialFilterExpression || {}]}; const count = await model.find(conditions).countDocuments(); return count === 0; diff --git a/package.json b/package.json index 680d510..7ee76b8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mongoose-unique-validator", - "version": "3.0.1", + "version": "3.0.2", "description": "mongoose-unique-validator is a plugin which adds pre-save validation for unique fields within a Mongoose schema.", "main": "index.js", "scripts": {