Skip to content
MyAppBuilder
StableGuide

Queries

A query is the instruction a component uses to fetch records: show Jobs where Status is "Open", newest first, at most 50 . Tables, cards, lists, data grids, kanban boards, calendars, timelines, galleries, charts and KPIs all read their records through a query configured on the co

A query is the instruction a component uses to fetch records: show Jobs where Status is "Open", newest first, at most 50. Tables, cards, lists, data grids, kanban boards, calendars, timelines, galleries, charts and KPIs all read their records through a query configured on the component's Data tab. Queries are evaluated on the server with the signed-in user's permissions, so a role never sees records it is not allowed to see, whatever the filter says.

When to use

Set a query on every component that shows records. Use filters to narrow the list, a sort to order it, a limit to cap it, Search from to connect a search box, and aggregates for totals.

Set up a query

  1. Select the component and open the Data tab.
  2. Source: Database (an entity) or API (an external API source). None disconnects.
  3. Entity: the entity to read from. The default sort is Created, descending.
  4. Filters: rows of field · operator · value. Values may be fixed or dynamic (data picker). All filters must match. See Filters.
  5. Sort by and Direction. See Sorting.
  6. Maximum records: leave empty for no limit (paging still applies).
  7. Search from: pick a search box or input on the same page; typing in it filters the records as people type.

Two shortcuts add the most common filters:

  • Record from page URL (:id) adds ID is Page parameter › id and limits the query to one record — for detail pages.
  • Only the signed-in user's adds Email field is Current user › email — for portal lists.

Dynamic filter values

Filter values can come from the data picker: page parameters, query parameters, app or page state, the current user, component state (for example a select input's value). A filter whose dynamic value is empty is skipped, so an optional filter shows everything until a value is chosen. Permission rules behave differently: an unresolved rule denies access.

Aggregates

KPIs and charts use aggregate queries: count, sum, avg, min or max of a field, optionally grouped by a field (groups follow the option order of a select field). The data picker's Database group offers Entity (count) for any bindable property, for example a heading that reads 12 open jobs.

Search matches text, long text, email, phone, URL and select fields, case-insensitively. Connect it with Search from rather than a filter so people can type freely.

What the server does

Filters, search, sort, limit and paging are applied on the server after the role's entity rules and record-level rules, and hidden fields are removed from the result. A query never widens what a role may see.

Examples

Example
Open jobs for staff:      Jobs · Status is "Open" · sort Scheduled For ascending
This customer's quotes:   Quotes · Customer Email is Current user › email · sort Created desc
One job on /jobs/:id:     Jobs · ID is Page parameter › id · limit 1
Revenue this month (KPI): Invoices · sum of Amount · Status is "Paid"
Jobs by status (chart):   Jobs · count · group by Status

Common mistakes

  • Filtering on a select's label instead of its value: compare with the option value.
  • Using a filter for the search box: use Search from; a filter with contains would require the operator to be chosen per field.
  • Expecting a filter to hide records from a role: filters are convenience; permissions are security.
  • Forgetting the limit on a dashboard list: set Maximum records so the page stays fast.

Related

Was this helpful?