Skip to content
Open Saka

Query views

A query view shows the results of a query in a grid that updates as the data changes. The grid only shows results; change data in the REPL.

The Views sidebar has a view for each role declared in your database’s files, with a row for each member and a column for each property. A role declared inside a mod block has none, and neither has one from the standard library. Dropping a role removes its view.

  1. Click New view, the plus button at the top of Views. The view opens with its formula ready to type.
  2. Type a formula, such as Book if .pages > 450.
  3. Choose Run or press ⌘Enter, or Ctrl+Enter on Windows and Linux.

To edit a formula again, double-click its query’s header, or press Enter or F2 on it. In a formula, Enter adds a line, and Escape stops editing.

A view’s formulas use the names of one file, which the selector beside Run shows. New views use main.saka. A database without it shows “Select Module…”, and Run stays disabled until you choose a file.

Choose Add child query in a query’s header menu to add a query that runs once for each row of its parent. Each query has an alias, q1 for the first. A child reads its parent’s row by the parent’s alias, and also as ., as in .title.

For example, the root query crm::Company with the child crm::Contact if .company == q1 lists each company with its contacts. Inside if, . is each contact, as in any pipeline, so the child names the company by its alias, q1.

  • Enter on a cell, or a double-click, shows its whole value in the Editor panel.
  • ⌘C or Ctrl+C copies the selected cells as text. Copy with headers, in a cell’s menu, adds the column names.
  • Sort ascending and Sort descending, in a column header’s menu, sort the rows.

Drag across cells, or hold Shift while you click or move, to select a range.

A formula with an error shows the reason and keeps the previous results. A query that takes too long or builds too much data shows Limited · Retry; see Limits.

Views belong to the browser tab. Reloading the page or updating Saka clears your own views; role views return.