Filtering & Sorting
Filter, sort, and paginate queries. These options work the same in both the server client and the hooks.
Filter Structure
example.ts
1
2
3
4
5
6
7
8
9
10
filter: {
query: [{
condition: {
field: 'name',
operator: 'equal',
value: 'Acme Corp',
},
}],
sortby: [{ field: 'created_at', order: 'desc' }],
}Operators
String
| Operator | Description | Example value |
|---|---|---|
equal | Exact match | "value" |
notEqual | Not equal | "value" |
like | Pattern match (case-sensitive) | "%search%" |
ilike | Pattern match (case-insensitive) | "%search%" |
notLike | Not pattern match | "%exclude%" |
notiLike | Not pattern match (case-insensitive) | "%exclude%" |
startsWith | Starts with | "prefix" |
endsWith | Ends with | "suffix" |
Number & Date
| Operator | Description |
|---|---|
equal | Equal to |
notEqual | Not equal to |
greaterThan | Greater than |
lessThan | Less than |
greaterThanOrEqual | Greater than or equal |
lessThanOrEqual | Less than or equal |
Null & Empty
| Operator | Description |
|---|---|
isNull | Field is null |
isNotNull | Field is not null |
isEmpty | Empty string |
isNotEmpty | Not empty |
These operators don't require a value.
Boolean
| Operator | Description |
|---|---|
isTrue | Field is true |
isFalse | Field is false |
List
| Operator | Description |
|---|---|
in | Value in list |
notIn | Value not in list |
Use values instead of value for list operators:
example.ts
1
2
3
4
5
condition: {
field: 'status',
operator: 'in',
values: ['paid', 'pending'],
}AND / OR
AND — all conditions must match:
example.ts
1
2
3
4
5
6
7
8
filter: {
query: [{
and: [
{ condition: { field: 'amount_net', operator: 'greaterThan', value: '1000' } },
{ condition: { field: 'status', operator: 'equal', value: 'paid' } },
],
}],
}OR — any condition can match:
example.ts
1
2
3
4
5
6
7
8
filter: {
query: [{
or: [
{ condition: { field: 'name', operator: 'ilike', value: '%acme%' } },
{ condition: { field: 'name', operator: 'ilike', value: '%corp%' } },
],
}],
}Sorting
example.ts
1
2
3
4
5
6
filter: {
sortby: [
{ field: 'created_at', order: 'desc' },
{ field: 'name', order: 'asc' },
],
}Multiple sort fields are applied in order (primary sort first).
Pagination
example.ts
1
2
3
4
pagination: {
page: 1, // Page number (1-indexed)
per_page: 20, // Items per page
}Response includes:
| Field | Type | Description |
|---|---|---|
total | number | Total number of matching entities |
current_page | number | Current page number |
per_page | number | Items per page |
last_page | number | Last available page number |
has_more_pages | boolean | Whether more pages exist |