From efb6d432eacbbebe1dc28e9ed5a1ef1f7419b670 Mon Sep 17 00:00:00 2001 From: regevbr Date: Sat, 30 Nov 2019 19:32:31 +0200 Subject: [PATCH] Fix bug #1795 Count issues related models --- lib/scope.js | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/lib/scope.js b/lib/scope.js index 712bcd9b6..e2d121539 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -421,11 +421,7 @@ function defineScope(cls, targetClass, name, params, methods, options) { // run another query to apply filter on relatedModel(targetModel) // see github.com/strongloop/loopback-datasource-juggler/issues/1795 let scopeOnRelatedModel = false; - let queryRelated; - let keyFrom; - let relatedModel; - let IdKey; - let fieldsRelated; + let queryRelated, keyFrom, relatedModel, IdKey, fieldsRelated; if (this._scope && this._scope.collect && where !== null && typeof where === 'object') { queryRelated = { @@ -480,11 +476,7 @@ function defineScope(cls, targetClass, name, params, methods, options) { // run another query to apply filter on relatedModel(targetModel) // see github.com/strongloop/loopback-datasource-juggler/issues/1795 let scopeOnRelatedModel = false; - let queryRelated; - let keyFrom; - let relatedModel; - let IdKey; - let fieldsRelated; + let queryRelated, keyFrom, relatedModel, IdKey, fieldsRelated; if (this._scope && this._scope.collect && where !== null && typeof where === 'object') { queryRelated = { @@ -567,10 +559,7 @@ function defineScope(cls, targetClass, name, params, methods, options) { // run another query to apply filter on relatedModel(targetModel) // see github.com/strongloop/loopback-datasource-juggler/issues/1795 let scopeOnRelatedModel = false; - let queryRelated; - let keyFrom; - let relatedModel; - let IdKey; + let queryRelated, keyFrom, relatedModel, IdKey; if (this._scope && this._scope.collect && filter && filter.where !== null && typeof filter.where === 'object') { queryRelated = { @@ -624,11 +613,7 @@ function defineScope(cls, targetClass, name, params, methods, options) { // run another query to apply filter on relatedModel(targetModel) // see github.com/strongloop/loopback-datasource-juggler/issues/1795 let scopeOnRelatedModel = false; - let queryRelated; - let keyFrom; - let relatedModel; - let IdKey; - let fieldsRelated; + let queryRelated, keyFrom, relatedModel, IdKey, fieldsRelated; if (this._scope && this._scope.collect && where !== null && typeof where === 'object') { queryRelated = {