Filters optimized for numeric values

This commit is contained in:
Juan 2018-07-03 17:41:41 +02:00
parent 3208cc7851
commit b49bd3d903
3 changed files with 9 additions and 18 deletions

View File

@ -10,12 +10,9 @@ export default class Controller {
exprBuilder(param, value) { exprBuilder(param, value) {
switch (param) { switch (param) {
case 'search': case 'search':
return { return /^\d+$/.test(value)
or: [ ? {id: value}
{id: value}, : {name: {regexp: value}};
{name: {regexp: value}}
]
};
case 'phone': case 'phone':
return { return {
or: [ or: [

View File

@ -28,12 +28,9 @@ class Controller {
exprBuilder(param, value) { exprBuilder(param, value) {
switch (param) { switch (param) {
case 'search': case 'search':
return { return /^\d+$/.test(value)
or: [ ? {id: value}
{id: value}, : {name: {regexp: value}};
{name: {regexp: value}}
]
};
case 'name': case 'name':
case 'description': case 'description':
return {[param]: {regexp: value}}; return {[param]: {regexp: value}};

View File

@ -59,12 +59,9 @@ export default class Controller {
exprBuilder(param, value) { exprBuilder(param, value) {
switch (param) { switch (param) {
case 'search': case 'search':
return { return /^\d+$/.test(value)
or: [ ? {id: value}
{id: value}, : {nickname: {regexp: value}};
{nickname: {regexp: value}}
]
};
case 'from': case 'from':
return {shipped: {gte: value}}; return {shipped: {gte: value}};
case 'to': case 'to':