Predicate
Predicates are used to filter queries.
Example:
const predicate = Predicate.equals(myNumberProperty, 1);
const filteredQuery = Query.instancesOf(myModel).filter(predicate).andReturn();
Constructors
new Predicate()
new Predicate(): Predicate
Returns
Predicate
Methods
and()
static and(...predicates): Predicate
Create an AND composite predicate matching a specified set of predicates
Parameters
| Parameter | Type | Description |
|---|---|---|
...predicates | Predicate[] | list of predicates to match |
Returns
Predicate
new Predicate that should match all specified predicates
contains()
static contains(
property,
value,
caseSensitive?): Predicate
Create a predicate matching a specified string property to a specified string.
Parameters
| Parameter | Type | Description |
|---|---|---|
property | Property<string> | the string property to use for filtering |
value | string | the value the string property must match |
caseSensitive? | boolean | if the match must pay attention to case sensitivity, default value is true |
Returns
Predicate
new Predicate with the contains string operation
equals()
static equals<T>(property, value): Predicate
Create a predicate matching a specified property to a specified value.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
property | Property<T> | the property to use for filtering |
value | T | the value the property must match |
Returns
Predicate
new Predicate with the equals operation
greaterThan()
Call Signature
static greaterThan(
property,
value,
strict?): Predicate
Create a predicate matching a specified number property to a numerical lower bound
Parameters
| Parameter | Type | Description |
|---|---|---|
property | Property<number> | the number property to user for filtering |
value | number | the lower bound |
strict? | boolean | if the inequality is strict or not |
Returns
Predicate
new Predicate with the greaterThan mathematical operation
Call Signature
static greaterThan(
property1,
property2,
strict?): Predicate
Create a predicate matching a specified number property to a number property lower bound
Parameters
| Parameter | Type | Description |
|---|---|---|
property1 | Property<number> | the number property to user for filtering |
property2 | Property<number> | the lower bound number property |
strict? | boolean | if the inequality is strict or not |
Returns
Predicate
new Predicate with the greaterThan mathematical operation
in()
static in(...tags): Predicate
Create a predicate to match the specified object(s).
Parameters
| Parameter | Type | Description |
|---|---|---|
...tags | InstanceOrTag[] | the object or unique identifier (tag) of the objects to look for. |
Returns
Predicate
not()
static not(predicate): Predicate
Create a NOT predicate matching the opposite of a specified predicate
Parameters
| Parameter | Type | Description |
|---|---|---|
predicate | Predicate | the predicate to inverse |
Returns
Predicate
new Predicate that match when the specified predicate does not
or()
static or(...predicates): Predicate
Create an OR composite predicate matching a specified set of predicates
Parameters
| Parameter | Type | Description |
|---|---|---|
...predicates | Predicate[] | list of predicates to match |
Returns
Predicate
new Predicate that should match at least one specified predicate
regex()
static regex(
property,
value,
caseSensitive?): Predicate
Create a predicate matching a specified string property to a regular expression.
Parameters
| Parameter | Type | Description |
|---|---|---|
property | Property<string> | the string property to use for filtering |
value | string | RegExp | the regex or pattern the string property must match |
caseSensitive? | boolean | if the match must pay attention to case sensitivity, default value is true |
Returns
Predicate
new Predicate with the match regex operation
smallerThan()
Call Signature
static smallerThan(
property,
value,
strict?): Predicate
Create a predicate matching a specified number property to a numerical upper bound
Parameters
| Parameter | Type | Description |
|---|---|---|
property | Property<number> | the number property to user for filtering |
value | number | the upper bound |
strict? | boolean | if the inequality is strict or not |
Returns
Predicate
new Predicate with the smallerThan mathematical operation
Call Signature
static smallerThan(
property1,
property2,
strict?): Predicate
Create a predicate matching a specified number property to a number property upper bound
Parameters
| Parameter | Type | Description |
|---|---|---|
property1 | Property<number> | the number property to user for filtering |
property2 | Property<number> | the upper bound number property |
strict? | boolean | if the inequality is strict or not |
Returns
Predicate
new Predicate with the smallerThan mathematical operation