ResourceFilter
Summary
Defines a storage filter.
A filter is a uniform way of filtering results common to all storages. A filter can contain only one "or" operation, one "nor" operation and one "and" operation.
var filter = new ResourceFilter()
.equal('field1', 42)
.notEqual('field2', 42)
.greaterThan('field3', 42)
.greaterThanEqual('field4', 42)
.in('field5', [42])
.lesserThan('field6', 42)
.lesserThanEqual('field7', 42)
.regex('field8', /^Something/i)
.search('query')
.or([
new ResourceFilter().equal('field8', 42),
new ResourceFilter().notIn('field9', [42])
])
.nor([
new ResourceFilter().equal('field10', 42),
new ResourceFilter().notIn('field11', [42])
)],
.and([
new ResourceFilter().equal('field12', 42),
new ResourceFilter().notIn('field13', [42])
)];
Constructor
ResourceFilter
Syntax
ResourceFilter
()
Summary
Methods
addComparisonOperation
Syntax
Summary
Adds a comparison operation to the filter.
Parameters:
Returns:
The actual filter
addLogicalOperation
Syntax
Summary
Adds a logical operation to the filter.
Only one logical operation can be added in a filter.
Parameters:
-
filters
ArrayThe list of filters
Returns:
The actual filter
and
Syntax
Summary
Adds an "and" operation to the filter.
Parameters:
-
filters
ArrayThe list of filters
Returns:
The actual filter
equal
Syntax
Summary
Adds an equal operation to the filter.
Parameters:
Returns:
The actual filter
equal
Syntax
Summary
Adds a "not equal" operation to the filter.
Parameters:
Returns:
The actual filter
getComparisonOperation
Syntax
Summary
Gets an operation from filter or sub filters.
Returns:
The operation with: -String type The operation type -String field The operation field -String|Number|Boolean|Date|Array value The operation value
getLogicalOperation
Syntax
Summary
Gets a logical operation from filter.
Parameters:
-
operator
StringLogical operator to look for
Returns:
The operation with: -String type The operation type -Array filters The list of filters inside the logical operation
greaterThan
Syntax
Summary
Adds a "greater than" operation to the filter.
Parameters:
Returns:
The actual filter
greaterThanEqual
Syntax
Summary
Adds a "greater than or equal" operation to the filter.
Parameters:
Returns:
The actual filter
hasOperation
Syntax
Summary
Tests if an operation has already been specified.
Parameters:
-
operator
StringOperation operator
Returns:
true if the operation has already been added to this filter, false otherwise
in
Syntax
Summary
Adds a "not in" operation to the filter.
Returns:
The actual filter
isValidType
Syntax
Summary
Validates the type of a value.
Returns:
true if valid, false otherwise
lesserThan
Syntax
Summary
Adds a "lesser than" operation to the filter.
Parameters:
Returns:
The actual filter
lesserThanEqual
Syntax
Summary
Adds a "lesser than equal" operation to the filter.
Parameters:
Returns:
The actual filter
nor
Syntax
Summary
Adds a "nor" operation to the filter.
Parameters:
-
filters
ArrayThe list of filters
Returns:
The actual filter
or
Syntax
Summary
Adds a "or" operation to the filter.
Parameters:
-
filters
ArrayThe list of filters
Returns:
The actual filter
regex
Syntax
Summary
Adds a "regular expression" operation to the filter.
Parameters:
Returns:
The actual filter
search
Syntax
Summary
Adds a "search" operation to the filter.
Parameters:
-
value
StringThe search query
Returns:
The actual filter