Live queries
A live query is a search inside a page. It shows the matching lines and keeps up as the workspace changes. Use it for a dashboard, a project review, or the list of things waiting on you.
Make one
Run a search and drag the query from the search panel onto a page. Or pick Live Query from the @-menu and type the query. Change query in the block’s menu edits it later. Give the block a heading that says what it shows, such as “Overdue” above @todo @overdue. A block without a query shows @today.
What it shows
- The results are the real lines, not copies. Edit one or tick a task off, and the change is made in the page it lives on.
- Up to 100 results: pages first, then lines by default. Add
@sort=to choose an order. Lines that start matching are added at the end. - A line that stops matching, such as a task you just ticked off, stays in the block until it loads again, for example when you open the page again.
- With nothing to show, the block says “No results”. A query that can’t run shows its error in the block.
- The block folds like any other section.
Sorting results
Add @sort=due to put earlier dates first, or @sort=-modified_at for the most recently changed results first. You can also sort by a collection property, including names with spaces: @page @sort=-"My project"."my attribute".
For tasks, use @task @sort=done to order by status, or @todo @sort=user by mentioned person. @sort=page brings results from the same page together, and @sort=type brings tasks, headings and other line types together. A query such as @todo @sort=Projects.Priority sorts tasks by the Priority property on their containing project page. Repeat @sort= to break ties: @task @sort=done @sort=due sorts by status first, then by date within each status.
Sorting applies when the block loads or refreshes. Results stay in place while you edit them, and new matches appear at the end. The same sorting works in Related and Upcoming sections. See Sorting for all keys and how property values are ordered.
Pages instead of lines
A query matches lines anywhere in the workspace, so one block can show a task from one page next to a paragraph from another. Add @page to get only pages: each result is a page, matched on its title and properties, not on the lines inside it. That makes a box of related pages, such as on a customer’s page:
@page @linkto="Acme" pages with Acme in a Page Link property
@page @Projects.Status="In progress" active projects
@page @created_at = thisweek pages created this week
A dashboard page
A team page works well with three or four narrow queries:
@todo @overdue overdue work
@due = thisweek due this week
@todo @waiting waiting on others
@discuss open questions
Add links to the project board and the handbook, and pin the page. For a table or board of pages from several collections, use a dynamic collection instead.
Related content on every page
A collection can show a query at the top of each of its pages, with the page itself as the context. Set it in Collection Settings… → Related. Two variables make it work: $currentpage for the page being viewed, $currentcollection for its collection. They are filled in only here, not in live query blocks.
@task @linkto=$currentpage tasks that link to this page
@linkto=$currentpage anything that links to it
@task @linkto=$currentcollection tasks that link to the collection
With this, a project page lists every action that mentions it, wherever those actions were written. The Journal’s Upcoming section is the same mechanism with a date-aware query.
The Query language reference lists every filter, has dozens of examples, and explains the variables that Related and Upcoming fill in.