From 23fdfcc23dde16d3b49f0c990e3a14360155a44e Mon Sep 17 00:00:00 2001 From: knacharam-rythmos Date: Tue, 23 Oct 2018 11:07:34 +0530 Subject: [PATCH 1/3] fix for https://github.com/matteodelabre/mongoose-beautiful-unique-validation/issues/57 --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 029571e..349b516 100644 --- a/index.js +++ b/index.js @@ -68,7 +68,7 @@ function collectMessages(tree) { tree[key].unique = true; } else { // Nested schema - var subtree = collectMessages(tree[key]); + var subtree = collectMessages(tree[key].tree); for (var subkey in subtree) { if (subtree.hasOwnProperty(subkey)) { From e78f7cc0a38b9464a42831cd5f76b9b7c2a88a18 Mon Sep 17 00:00:00 2001 From: knacharam-rythmos Date: Tue, 23 Oct 2018 18:29:05 +0530 Subject: [PATCH 2/3] Updated the reading custom message logic. https://github.com/matteodelabre/mongoose-beautiful-unique-validation/issues/57 --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 349b516..ccfc7f1 100644 --- a/index.js +++ b/index.js @@ -68,7 +68,7 @@ function collectMessages(tree) { tree[key].unique = true; } else { // Nested schema - var subtree = collectMessages(tree[key].tree); + var subtree = collectMessages(tree[key].tree || tree[key]); for (var subkey in subtree) { if (subtree.hasOwnProperty(subkey)) { From eb4dc28a2b85b6fe5b7504998202921a8b14404d Mon Sep 17 00:00:00 2001 From: knacharam-rythmos Date: Mon, 5 Nov 2018 16:54:18 +0530 Subject: [PATCH 3/3] Added the updateOne updateMany hooks. https://github.com/matteodelabre/mongoose-beautiful-unique-validation/issues/60 --- index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/index.js b/index.js index ccfc7f1..452c6c9 100644 --- a/index.js +++ b/index.js @@ -242,5 +242,7 @@ module.exports = function (schema, options) { schema.post('save', postHook); schema.post('update', postHook); + schema.post('updateOne', postHook); + schema.post('updateMany', postHook); schema.post('findOneAndUpdate', postHook); };