From f82a61694062de32dd5d44b7ddab6db1bf106147 Mon Sep 17 00:00:00 2001 From: Daniel Herrero Date: Wed, 7 Mar 2018 14:13:30 +0100 Subject: [PATCH] semantic refactor --- services/loopback/common/methods/client/filter.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/services/loopback/common/methods/client/filter.js b/services/loopback/common/methods/client/filter.js index 2c79e0556..bb1288630 100644 --- a/services/loopback/common/methods/client/filter.js +++ b/services/loopback/common/methods/client/filter.js @@ -40,16 +40,17 @@ module.exports = function(Client) { delete params.phone; } - let keys = Object.keys(params); - if (keys.length) { - keys.forEach( - key => { + let properties = Object.keys(params); + if (properties.length) { + properties.forEach( + property => { + let propertyToBeEqual = (property === 'postcode' || property === 'fi' || property === 'id'); if (filters.where.and) { let filter = {}; - filter[key] = (key === 'postcode' || key === 'fi' || key === 'id') ? params[key] : {regexp: params[key]}; + filter[property] = propertyToBeEqual ? params[property] : {regexp: params[property]}; filters.where.and.push(filter); } else { - filters.where[key] = (key === 'postcode' || key === 'fi' || key === 'id') ? params[key] : {regexp: params[key]}; + filters.where[property] = propertyToBeEqual ? params[property] : {regexp: params[property]}; } } );