Skip to main content
Version: 2.13

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​

ParameterTypeDescription
...predicatesPredicate[]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​

ParameterTypeDescription
propertyProperty<string>the string property to use for filtering
valuestringthe value the string property must match
caseSensitive?booleanif 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​

ParameterTypeDescription
propertyProperty<T>the property to use for filtering
valueTthe 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​
ParameterTypeDescription
propertyProperty<number>the number property to user for filtering
valuenumberthe lower bound
strict?booleanif 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​
ParameterTypeDescription
property1Property<number>the number property to user for filtering
property2Property<number>the lower bound number property
strict?booleanif 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​

ParameterTypeDescription
...tagsInstanceOrTag[]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​

ParameterTypeDescription
predicatePredicatethe 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​

ParameterTypeDescription
...predicatesPredicate[]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​

ParameterTypeDescription
propertyProperty<string>the string property to use for filtering
valuestring | RegExpthe regex or pattern the string property must match
caseSensitive?booleanif 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​
ParameterTypeDescription
propertyProperty<number>the number property to user for filtering
valuenumberthe upper bound
strict?booleanif 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​
ParameterTypeDescription
property1Property<number>the number property to user for filtering
property2Property<number>the upper bound number property
strict?booleanif the inequality is strict or not
Returns​

Predicate

new Predicate with the smallerThan mathematical operation