semantic refactor

This commit is contained in:
Daniel Herrero 2018-03-07 14:13:30 +01:00
parent 43bfbf3f4b
commit f82a616940
1 changed files with 7 additions and 6 deletions

View File

@ -40,16 +40,17 @@ module.exports = function(Client) {
delete params.phone; delete params.phone;
} }
let keys = Object.keys(params); let properties = Object.keys(params);
if (keys.length) { if (properties.length) {
keys.forEach( properties.forEach(
key => { property => {
let propertyToBeEqual = (property === 'postcode' || property === 'fi' || property === 'id');
if (filters.where.and) { if (filters.where.and) {
let filter = {}; 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); filters.where.and.push(filter);
} else { } else {
filters.where[key] = (key === 'postcode' || key === 'fi' || key === 'id') ? params[key] : {regexp: params[key]}; filters.where[property] = propertyToBeEqual ? params[property] : {regexp: params[property]};
} }
} }
); );