Filter, order and paginate the rows a request returns.
#Filters
| Operation | Request |
|---|---|
| Filter | GET /rest/v1/todos?is_complete=eq.true&id=gt.10 |
| Order and paginate | GET /rest/v1/todos?order=created_at.desc&limit=20&offset=40 |
| Operator | SDK | Meaning |
|---|---|---|
eq, neq | .eq(), .neq() | Equal, not equal |
gt, gte, lt, lte | .gt() … | Greater / less than |
like, ilike | .like(), .ilike() | Pattern match (%), case-insensitive with ilike |
is | .is('col', null) | IS NULL, true, false |
in | .in('id', [1, 2]) | One of a list: ?id=in.(1,2) |
cs, cd, ov | .contains(), .containedBy(), .overlaps() | Arrays, JSON and ranges |
sl, sr, nxl, nxr, adj | .rangeLt(), .rangeGt(), .rangeGte(), .rangeLte(), .rangeAdjacent() | Range columns |
fts, plfts, phfts, wfts | .textSearch(col, q, { type }) | Full-text search |
not. | .not('col', 'is', null) | Negate any operator |
or=(…) | .or('a.eq.1,b.gt.2') | Any of several conditions |
JavaScript
const { data } = await stitchdb
.from('todos')
.select('id, task')
.eq('is_complete', false)
.gt('id', 10)
.or('task.ilike.%ship%,task.ilike.%launch%')
// Several equality filters at once, or any operator by name
await stitchdb.from('todos').select('*').match({ is_complete: false, user_id: uid })
await stitchdb.from('todos').select('*').filter('tags', 'cs', '{urgent}')
// Full-text search
await stitchdb.from('posts').select('*').textSearch('body', 'postgres & realtime', { type: 'websearch', config: 'english' })#Order and paginate
JavaScript
const { data } = await stitchdb
.from('todos')
.select('*')
.order('created_at', { ascending: false, nullsFirst: false })
.range(0, 9) // the first 10 rows
// Order related rows
await stitchdb.from('projects').select('name, todos(task)').order('created_at', { referencedTable: 'todos' })Use limit and offset (or range(), sent as a Range header) to page through results. The maximum number of rows per request is a plan limit: see API limits. For deep pages, filter on an indexed column (.gt('id', lastId)) instead of a large offset.