pagehive

query_table

Run a data query: where, any (AND-ed with where when both are set), search (with snippets), similar_to, sort, paging, group_by, aggregates (per group, or one totals row without group_by), include, fields, meta, count_only, and visibility.

TablesRead-onlyAll plansUpdated

What it does

Run a data query: where, any (AND-ed with where when both are set), search (with snippets), similar_to, sort, paging, group_by, aggregates (per group, or one totals row without group_by), include, fields, meta, count_only, and visibility. where takes length_gt, length_gte, length_lt, length_lte and length_between on text columns; sort takes length(column). The SQL runs in Postgres. Sort keeps the first occurrence of each column and allows at most 5 distinct columns. On an own_and_shared table a member or site agent reads the shared rows plus its own private rows; visibility narrows that to shared or private.

Plans

Works on every plan: Free, Basic, Pro and Ultra.

Parameters

NameTypeAbout
tablerequiredstringThe table to query.
whereobjectFilters by column, all of which must match: a value, or one operator such as {"gte": 10}, {"contains": "x"}, {"empty": true} or {"length_gt": 30000} on a text column.
anyarray of objectsA list of where filters, of which at least one must match.
searchstringText to find in the table's searchable columns.
snippetsbooleanWith search: true adds _snippets (for each searchable text column that matched, a short excerpt with the matched words in **bold**) and _rank to every row.
similar_tostringText to compare against, at most 500 characters: returns rows whose text is like it (trigram word similarity), most similar first unless you sort, each with _similarity from 0 to 1.
similar_columnsarray of stringText columns similar_to compares, joined. Default: the table's searchable text columns. Short columns (a title, a summary) are faster and match better than long ones.
similar_minnumberLowest _similarity kept, from 0 to 1. Default 0.3.
sortstring or array of stringA column to sort by, or length(column) for a text column's length; a leading - sorts descending. A list sorts by several columns.
limitnumberHow many rows to return per page.
pagenumberThe page number, starting at 1.
cursorstringThe next_cursor from the previous page, to continue.
group_bystringA column to group by. Returns one row per value with its count and the aggregates you ask for. Not with fields.
sumarray of stringColumns to add up, per group, or without group_by in one totals row for the whole result.
avgarray of stringColumns to average.
minarray of stringColumns to return the smallest value of.
maxarray of stringColumns to return the largest value of.
includearray of stringRelation columns whose linked rows to include in each row.
fieldsarray of stringColumn keys to return, such as ["slug","title"]. key:N returns the first N characters of a text column (rows it cut list it in _truncated); length(key) returns length_<key>, its length in characters. id, position, revision, created_at, updated_at, _member, _created_by and _updated_by always come back (only id and revision with meta min). Filters, search and sort can use other columns. Not with group_by or aggregates. It keeps long text columns out of the response.
metaone of: full, minfull (default) or min: each row carries only id and revision beside its values, with no position, times, _member, _created_by or _updated_by.
count_onlybooleantrue returns only total (the number of matching rows, or of groups with group_by), with no rows.
visibilityone of: shared, private, allOnly for an own_and_shared table. shared: rows that belong to no member. private: your own private rows (the owner: every member's). all, the default: everything you may read, so the shared rows plus your own.
site_idstringOnly for a site shared with you (whoami lists them): read or change that site's data as its member.

Example

Call query_table with these arguments:

{
  "table": "recipes",
  "where": {
    "vegetarian": true,
    "minutes": {
      "lte": 30
    }
  },
  "sort": "minutes",
  "limit": 20,
  "fields": [
    "title",
    "minutes"
  ]
}

Ids like 01a1… stand for your own. list_sites and list_tables give you the real ones.

Related guides