@@ -5,7 +5,7 @@ import { NoMatchingOperatorError } from './errors';
5
5
const { getReferenceSchema, getReferenceField } = require ( '../utils/query' ) ;
6
6
7
7
function FiltersParser ( modelSchema , timezone , options ) {
8
- this . OPERATORS = new Operators ( options ) ;
8
+ this . OPERATORS = Operators . getInstance ( options ) ;
9
9
this . operatorDateParser = new BaseOperatorDateParser ( { operators : this . OPERATORS , timezone } ) ;
10
10
11
11
this . perform = async ( filtersString ) =>
@@ -59,58 +59,6 @@ function FiltersParser(modelSchema, timezone, options) {
59
59
}
60
60
} ;
61
61
62
- this . formatOperator = ( operator ) => {
63
- switch ( operator ) {
64
- case 'not' :
65
- return this . OPERATORS . NOT ;
66
- case 'greater_than' :
67
- case 'after' :
68
- return this . OPERATORS . GT ;
69
- case 'less_than' :
70
- case 'before' :
71
- return this . OPERATORS . LT ;
72
- case 'contains' :
73
- case 'starts_with' :
74
- case 'ends_with' :
75
- return this . OPERATORS . LIKE ;
76
- case 'not_contains' :
77
- return this . OPERATORS . NOT_LIKE ;
78
- case 'present' :
79
- case 'not_equal' :
80
- return this . OPERATORS . NE ;
81
- case 'blank' :
82
- case 'equal' :
83
- return this . OPERATORS . EQ ;
84
- default :
85
- throw new NoMatchingOperatorError ( ) ;
86
- }
87
- } ;
88
-
89
- this . formatValue = ( operator , value ) => {
90
- switch ( operator ) {
91
- case 'not' :
92
- case 'greater_than' :
93
- case 'less_than' :
94
- case 'not_equal' :
95
- case 'equal' :
96
- case 'before' :
97
- case 'after' :
98
- return value ;
99
- case 'contains' :
100
- case 'not_contains' :
101
- return `%${ value } %` ;
102
- case 'starts_with' :
103
- return `${ value } %` ;
104
- case 'ends_with' :
105
- return `%${ value } ` ;
106
- case 'present' :
107
- case 'blank' :
108
- return null ;
109
- default :
110
- throw new NoMatchingOperatorError ( ) ;
111
- }
112
- } ;
113
-
114
62
this . formatOperatorValue = ( operator , value , isTextField = false ) => {
115
63
switch ( operator ) {
116
64
case 'not' :
@@ -143,6 +91,8 @@ function FiltersParser(modelSchema, timezone, options) {
143
91
} : { [ this . OPERATORS . EQ ] : null } ;
144
92
case 'equal' :
145
93
return { [ this . OPERATORS . EQ ] : value } ;
94
+ case 'includes_all' :
95
+ return { [ this . OPERATORS . CONTAINS ] : value } ;
146
96
default :
147
97
throw new NoMatchingOperatorError ( ) ;
148
98
}
0 commit comments