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) {
switch (param) {
case 'search':
return {
or: [
{id: value},
{name: {regexp: value}}
]
};
return /^\d+$/.test(value)
? {id: value}
: {name: {regexp: value}};
case 'phone':
return {
or: [

View File

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

View File

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