Filtering and sorting
Filtering
Alerts API provides capabilities to filter and sort its output. It's achieved by using the where
argument on the alerts
node of the Craft API.
where
allows constructing an expression that will be matched against the available Alerts and filter. The general syntax is to use the field from the Alert entity and compare it with a certain value using a specific operator.
Please, see the AlertBoolExpression type definition for all of the available fields and operators available.
It's also possible to specify multiple fields which will be combined with a logical "AND":
In such case, API will return Alerts where firstField
and secondField
are matching provided values.
Filter examples
For the query above, $where
variable may have following shapes:
Sorting
By default Alerts API output is sorted chronologically by publishedAt
field in descending (most recent Alerts first) order. To change the order to ascending order (oldest published Alerts first), it's possible to specify the orderBy
argument on the alerts
node:
Please, see the orderBy type definition for all the possible fields and values.
Last updated