Query records
A Database query starts with a table and composes only the operations the application needs: filters, ordering, field selection, and pagination. TaruviBase returns the current page together with the complete matching count.
The examples use tasks from the
quickstart.
Filter, sort, and paginate
Return the first 20 tasks whose title contains release, in title order with
id as the final tie-breaker.
- JavaScript SDK
- Python SDK
- Refine
- REST API
- TaruviBase Console
await database
.from('tasks')
.filters('title', 'contains', 'release')
.sort('title', 'asc')
.sort('id', 'asc')
.page(1)
.pageSize(20)
.execute();
(
client.database
.from_("tasks")
.filter("title", "contains", "release")
.sort("title", "asc")
.sort("id", "asc")
.page(1)
.page_size(20)
.execute()
)
useList({
resource: 'tasks',
filters: [{field: 'title', operator: 'contains', value: 'release'}],
sorters: [
{field: 'title', order: 'asc'},
{field: 'id', order: 'asc'},
],
pagination: {currentPage: 1, pageSize: 20, mode: 'server'},
});
/api/apps/$TARUVI_APP_SLUG/datatables/tasks/data/curl "$TARUVI_SITE_URL/api/apps/$TARUVI_APP_SLUG/datatables/tasks/data/?title__contains=release&ordering=title%2Cid&page=1&page_size=20" \
-H "Authorization: Api-Key $TARUVI_API_KEY"
200Returns matching records in data and the complete matching count in total.
- Open
tasks, select Data, then select Filters. - Select Add first condition, choose
title, select Contains, and enterrelease. - Select Sort, then add
titleascending andidascending. - Select Apply. Use the data-grid pagination controls to move through the matching records.
Pages are one-indexed. Stable ordering makes an unchanged result set deterministic. Separate page requests do not share a database snapshot, so concurrent inserts, updates, or deletes can move records between pages.
Select response fields
Project only the fields used by the application when the interface supports server-side field selection.
- JavaScript SDK
- Refine
- REST API
await database
.from('tasks')
.fields('id,title,done')
.sort('title', 'asc')
.sort('id', 'asc')
.page(1)
.pageSize(20)
.execute();
useList({
resource: 'tasks',
sorters: [
{field: 'title', order: 'asc'},
{field: 'id', order: 'asc'},
],
pagination: {currentPage: 1, pageSize: 20, mode: 'server'},
meta: {select: ['id', 'title', 'done']},
});
/api/apps/$TARUVI_APP_SLUG/datatables/tasks/data/curl "$TARUVI_SITE_URL/api/apps/$TARUVI_APP_SLUG/datatables/tasks/data/?fields=id%2Ctitle%2Cdone&ordering=title%2Cid&page=1&page_size=20" \
-H "Authorization: Api-Key $TARUVI_API_KEY"
200Returns only the selected fields for each matching record.
Match every condition
Flat filters use AND logic. This query finds incomplete tasks whose title
contains release.
- JavaScript SDK
- Python SDK
- Refine
- REST API
await database
.from('tasks')
.filters('done', 'eq', false)
.filters('title', 'contains', 'release')
.sort('title', 'asc')
.sort('id', 'asc')
.page(1)
.pageSize(20)
.execute();
(
client.database
.from_("tasks")
.filter("done", "eq", False)
.filter("title", "contains", "release")
.sort("title", "asc")
.sort("id", "asc")
.page(1)
.page_size(20)
.execute()
)
useList({
resource: 'tasks',
filters: [
{field: 'done', operator: 'eq', value: false},
{field: 'title', operator: 'contains', value: 'release'},
],
sorters: [
{field: 'title', order: 'asc'},
{field: 'id', order: 'asc'},
],
pagination: {currentPage: 1, pageSize: 20, mode: 'server'},
});
/api/apps/$TARUVI_APP_SLUG/datatables/tasks/data/curl "$TARUVI_SITE_URL/api/apps/$TARUVI_APP_SLUG/datatables/tasks/data/?done=false&title__contains=release&ordering=title%2Cid&page=1&page_size=20" \
-H "Authorization: Api-Key $TARUVI_API_KEY"
200Returns records that match both filter conditions.
For nested logical groups, negation, set membership, text operators, null checks, arrays, and PostgreSQL range fields, use the filter operator reference.
Count matching records
The SDK count methods and REST total represent all matching records, not
only the current page. Refine exposes the same value as result.total.
- JavaScript SDK
- Python SDK
- Refine
- REST API
await database
.from('tasks')
.filters('done', 'eq', false)
.pageSize(1)
.count();
(
client.database
.from_("tasks")
.filter("done", "eq", False)
.page_size(1)
.count()
)
useList({
resource: 'tasks',
filters: [{field: 'done', operator: 'eq', value: false}],
pagination: {currentPage: 1, pageSize: 1, mode: 'server'},
meta: {select: ['id']},
});
/api/apps/$TARUVI_APP_SLUG/datatables/tasks/data/curl "$TARUVI_SITE_URL/api/apps/$TARUVI_APP_SLUG/datatables/tasks/data/?done=false&fields=id&page=1&page_size=1" \
-H "Authorization: Api-Key $TARUVI_API_KEY"
200Read the count from total in the response.
Request per-record action hints
A list query can ask TaruviBase which row-level actions are available for each
record. The response adds _allowed_actions to every row and includes a subset
of update and delete.
- JavaScript SDK
- Python SDK
- Refine
- REST API
await database
.from('tasks')
.allowedActions(['update', 'delete'])
.sort('id', 'asc')
.page(1)
.pageSize(20)
.execute();
(
client.database
.from_("tasks")
.allowed_actions(["update", "delete"])
.sort("id", "asc")
.page(1)
.page_size(20)
.execute()
)
useList({
resource: 'tasks',
sorters: [{field: 'id', order: 'asc'}],
pagination: {currentPage: 1, pageSize: 20, mode: 'server'},
meta: {allowedActions: ['update', 'delete']},
});
/api/apps/$TARUVI_APP_SLUG/datatables/tasks/data/curl "$TARUVI_SITE_URL/api/apps/$TARUVI_APP_SLUG/datatables/tasks/data/?allowed_actions=update%2Cdelete&ordering=id&page=1&page_size=20" \
-H "Authorization: Api-Key $TARUVI_API_KEY"
200Each row can include an _allowed_actions subset for the current caller.
Use these values to choose which controls to display. They are hints for the current response, not reusable permission grants; TaruviBase evaluates the actual authorization policy again when a mutation is submitted. Action hints cannot be combined with an aggregation query.
Plan indexes from real queries
Stable sorting is required for predictable pagination whether or not the sorted columns are indexed. When an important query becomes slow, capture its filters, ordering, representative parameters, row count, and latency, then use Plan indexes to prepare and verify the index change.
Validate query controls
Build queries from the supported operators and stay within the Database limits before sending them. Validate filter and sort input in your application instead of relying on API errors to catch bad input.
Query checklist
- Set
pageandpage_sizefor every collection read. - Use a stable order before moving through multiple pages.
- Before an export or bulk delete, pause writes or save the full list of record IDs first, so records don't shift between pages.
- Select only the fields the application needs where projection is supported.
- Read
totalseparately from the number of records on the current page. - Use a logical tree when AND and OR precedence matters.
- Treat
_allowed_actionsas display guidance and let every write authorize independently.