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.
For Refine, register the provider and sign in,
import useList from @refinedev/core, and place the hooks inside a component
beneath <Refine>.
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/Headers
AuthorizationApi-Key $TARUVI_API_KEY
Query parameters
title__containsreleaseorderingtitle,idpage1page_size20
View cURL
curl -G "$TARUVI_SITE_URL/api/apps/$TARUVI_APP_SLUG/datatables/tasks/data/" \
-H "Authorization: Api-Key $TARUVI_API_KEY" \
--data-urlencode 'title__contains=release' \
--data-urlencode 'ordering=title,id' \
--data-urlencode 'page=1' \
--data-urlencode 'page_size=20'
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
- Python SDK
- Refine
- REST API
await database
.from('tasks')
.fields('id,title,done')
.sort('title', 'asc')
.sort('id', 'asc')
.page(1)
.pageSize(20)
.execute();
(
client.database
.from_("tasks")
.filter("fields", "eq", "id,title,done")
.sort("title", "asc")
.sort("id", "asc")
.page(1)
.page_size(20)
.execute()
)
Pass comma-separated field names through .filter("fields", "eq", ...)
to select the response columns.
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/Headers
AuthorizationApi-Key $TARUVI_API_KEY
Query parameters
fieldsid,title,doneorderingtitle,idpage1page_size20
View cURL
curl -G "$TARUVI_SITE_URL/api/apps/$TARUVI_APP_SLUG/datatables/tasks/data/" \
-H "Authorization: Api-Key $TARUVI_API_KEY" \
--data-urlencode 'fields=id,title,done' \
--data-urlencode 'ordering=title,id' \
--data-urlencode 'page=1' \
--data-urlencode 'page_size=20'
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/Headers
AuthorizationApi-Key $TARUVI_API_KEY
Query parameters
donefalsetitle__containsreleaseorderingtitle,idpage1page_size20
View cURL
curl -G "$TARUVI_SITE_URL/api/apps/$TARUVI_APP_SLUG/datatables/tasks/data/" \
-H "Authorization: Api-Key $TARUVI_API_KEY" \
--data-urlencode 'done=false' \
--data-urlencode 'title__contains=release' \
--data-urlencode 'ordering=title,id' \
--data-urlencode 'page=1' \
--data-urlencode 'page_size=20'
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/Headers
AuthorizationApi-Key $TARUVI_API_KEY
Query parameters
donefalsefieldsidpage1page_size1
View cURL
curl -G "$TARUVI_SITE_URL/api/apps/$TARUVI_APP_SLUG/datatables/tasks/data/" \
-H "Authorization: Api-Key $TARUVI_API_KEY" \
--data-urlencode 'done=false' \
--data-urlencode 'fields=id' \
--data-urlencode 'page=1' \
--data-urlencode 'page_size=1'
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/Headers
AuthorizationApi-Key $TARUVI_API_KEY
Query parameters
allowed_actionsupdate,deleteorderingidpage1page_size20
View cURL
curl -G "$TARUVI_SITE_URL/api/apps/$TARUVI_APP_SLUG/datatables/tasks/data/" \
-H "Authorization: Api-Key $TARUVI_API_KEY" \
--data-urlencode 'allowed_actions=update,delete' \
--data-urlencode 'ordering=id' \
--data-urlencode 'page=1' \
--data-urlencode 'page_size=20'
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.