How Filtering Works
category.updatedAt
true
and false
. Others such as strings, enums, dates, should be quoted. For example: status : 'active'
Literal | Description | Example |
---|---|---|
and | and’s two expressions | status : ‘active’ and createdAt > ‘1-1-2000’ |
or | or’s two expressions | value ~ ‘%hello%’ or name ~ ‘%world%‘ |
not | not’s an expression | not (id > 100 or category.order is null) |
Literal | Description | Example |
---|---|---|
~ | checks if the left (string) expression is similar to the right (string) expression | catalog.name ~ ‘electronic’ |
~~ | similar to the previous operator but case insensitive | catalog.name ~~ ‘ElEcTroNic*‘ |
: | checks if the left expression is equal to the right expression | id : 5 |
! | checks if the left expression is not equal to the right expression | username ! ‘torshid’ |
> | checks if the left expression is greater than the right expression | distance > 100 |
>: | checks if the left expression is greater or equal to the right expression | distance >: 100 |
< | checks if the left expression is smaller than the right expression | distance < 100 |
<: | checks if the left expression is smaller or equal to the right expression | distance <: 100 |
isNull | checks if an expression is null | status isNull |
isNotNull | checks if an expression is not null | status isNotNull |
is empty | checks if the (collection) expression is empty | children is empty |
is not empty | checks if the (collection) expression is not empty | children is not empty |
in | checks if an expression is present in the right expressions | status in [‘initialized’, ‘active’] |
not in | checks if an expression is not present in the right expressions | status not in [‘failed’, ‘closed’] |
currentTime()
. Some
functions might also take arguments, arguments are separated with commas. For example: min(ratings) > 3
Name | Description | Example |
---|---|---|
absolute | returns the absolute | absolute(x) |
average | returns the average | average(ratings) |
min | returns the minimum | min(ratings) |
max | returns the maximum | max(ratings) |
sum | returns the sum | sum(a, b), sum(scores) |
diff | returns the difference | diff(a, b) |
prod | returns the product | prod(a, b) |
quot | returns the quotient | quot(a, b) |
mod | returns the modulus | mod(a, b) |
sqrt | returns the square root | sqrt(a) |
currentDate | returns the current date | currentDate() |
currentTime | returns the current time | currentTime() |
currentTimestamp | returns the current timestamp | currentTimestamp() |
size | returns the collection’s size | size(accidents) |
length | returns the string’s length | length(name) |
trim | returns the trimmed string | trim(name) |
upper | returns the uppercased string | upper(name) |
lower | returns the lowercased string | lower(name) |
concat | returns the concatenation of given strings | concat(firstName, ’ ’, lastName) |
Name | Description | Example | Explanation |
---|---|---|---|
exists | returns the existence of a subquery result | exists(employees.age > 60) | returns true if at least one employee’s age is greater than 60 |