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