From 916c179985de832bbd7d6d34bc12f67776f50096 Mon Sep 17 00:00:00 2001 From: Kaique da Silva Date: Wed, 14 Sep 2016 15:09:03 -0300 Subject: [PATCH 1/2] Grouping conditions --- src/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 34dff7e..b9be8d8 100644 --- a/src/index.js +++ b/src/index.js @@ -66,9 +66,10 @@ class Service { // into nested where conditions. if (method) { if (key === '$or') { - return value.forEach(condition => query[method].call(query, condition)); + return query.where(() => { + value.forEach(condition => this[method].call(this, condition)); + }); } - return query[method].call(query, column, value); } From fe780c7e3cc466efa1e59b61379a4047749db40d Mon Sep 17 00:00:00 2001 From: Kaique da Silva Date: Wed, 14 Sep 2016 16:39:29 -0300 Subject: [PATCH 2/2] Using function to get this in the right context --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index b9be8d8..f15885a 100644 --- a/src/index.js +++ b/src/index.js @@ -66,7 +66,7 @@ class Service { // into nested where conditions. if (method) { if (key === '$or') { - return query.where(() => { + return query.where(function() { value.forEach(condition => this[method].call(this, condition)); }); }