semantic refactor
This commit is contained in:
parent
43bfbf3f4b
commit
f82a616940
|
@ -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]};
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue