@@ -5,7 +5,7 @@ import { NoMatchingOperatorError } from './errors';
55const { getReferenceSchema, getReferenceField } = require ( '../utils/query' ) ;
66
77function FiltersParser ( modelSchema , timezone , options ) {
8- this . OPERATORS = new Operators ( options ) ;
8+ this . OPERATORS = Operators . getInstance ( options ) ;
99 this . operatorDateParser = new BaseOperatorDateParser ( { operators : this . OPERATORS , timezone } ) ;
1010
1111 this . perform = async ( filtersString ) =>
@@ -59,58 +59,6 @@ function FiltersParser(modelSchema, timezone, options) {
5959 }
6060 } ;
6161
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-
11462 this . formatOperatorValue = ( operator , value , isTextField = false ) => {
11563 switch ( operator ) {
11664 case 'not' :
@@ -143,6 +91,8 @@ function FiltersParser(modelSchema, timezone, options) {
14391 } : { [ this . OPERATORS . EQ ] : null } ;
14492 case 'equal' :
14593 return { [ this . OPERATORS . EQ ] : value } ;
94+ case 'includes_all' :
95+ return { [ this . OPERATORS . CONTAINS ] : value } ;
14696 default :
14797 throw new NoMatchingOperatorError ( ) ;
14898 }
0 commit comments