Skip to content

Queries#

A query is a saved filter over your collection: a set of rules that decides which notes appear. Saved queries live in the Queries section of the sidebar — click one and the note list narrows to exactly the notes that match. They're FoldNotes' answer to "show me everything that's actually relevant right now" without moving or copying a single note.

Queries are the engine behind two surfaces that share the same rule model:

  • Saved queries in the sidebar — filter the note list in place (this page).
  • Database Views — the same rules, presented as a sortable, multi-column table.

Everything below about rules, operators, and how task rules select notes applies to both.

Creating a query#

To create a query, expand the Queries section of the sidebar — the Library on iPhone and iPad — and tap + New Query (on macOS you can also right-click the header → New Query…). The query builder opens:

  1. Add a rule — pick a field, an operator, and (for most fields) a value.
  2. Add more rules to refine — each new rule is another condition.
  3. Choose how the rules combine — All or Any (see below).
  4. Name and save — the query appears in the sidebar and syncs to your other devices.

Run a saved query any time by clicking it in the sidebar; run it from the command line with fn query run "<query name>".

How rules combine — All vs Any#

A query's rules are joined one of two ways:

  • All (AND) — a note must satisfy every rule. Narrows the result. "tagged #work and modified this week and has an overdue task."
  • Any (OR) — a note matching at least one rule qualifies. Widens the result. "tagged #urgent or favourited."

Fields and operators#

Each rule targets one field. The available operators depend on the field:

Field What it matches Typical operators
Tag The note's tags (hierarchical) is · is not · is under · is not under
Title, Content Text in the title or body contains · does not contain
Date created / modified When the note was made or last changed within last N days
Size Note length greater than · less than
Favourite / Trashed / Archived / Daily note Note flags is true · is false
Has tasks Whether the note contains any task is true · is false
Task due date Any task's due date is overdue · is today · is this week · is next week · before · after
Task priority Any task's priority is · is not
Task completion Whether tasks are complete is true (complete) · is false (incomplete)
Task project Any task's project is · is not · is under · is not under · is none
Task context Any task's context is · is not · contains · does not contain · is none

"is under" is the hierarchy operator: Task Project is under work matches work and every sub-project (work/marketing, work/marketing/launch), with the / boundary preventing work from matching workshop. Tags use it too.

How task rules select notes#

This is the part worth understanding, because it's the usual source of "why is this note here — or missing?" questions.

A query returns notes, not tasks. So a task-based rule asks a question about a note's tasks and includes the note if the answer is yes. Two consequences follow:

A rule matches a note if any single task qualifies#

Task Context is sarah returns every note that has at least one task tagged sarah — even if the note's other tasks aren't.

Adding a second rule narrows the notes, but the two rules can be answered by two different tasks. Task Context is sarah and Task Completion is false returns notes that have a sarah task and have some unfinished task — not necessarily the same one. To require one task to satisfy both, use a task group.

Task groups#

Click or tap + Add Task Rule in the query builder to start a task group — labelled "Has a task where ALL of:". Every rule inside it must hold for the same task:

Has a task where ALL of: Task Context is sarah · Task Completion is false

That returns exactly what you'd expect — notes with an unfinished sarah task. Without the group, a note whose sarah task was finished long ago would still match, so long as some other task were unfinished.

A few things worth knowing:

  • Only task fields go in a group — due date, priority, completion, project, context. Has tasks asks about the note, so it stays outside. (It's also redundant alongside a group: a group can only match a note that has tasks.)
  • A query can be nothing but a group if that's the whole question.
  • A group is always combined with and, even when the rules above it are set to Any.
  • Negative rules read differently inside a group. Outside, Task Project is not alpha means no task in the note is in alpha. Inside a group it means this task isn't in alpha — so a note with one alpha task and one beta task matches the grouped form but not the ungrouped one. Both are useful; pick the one you mean.
  • Existing saved queries are unaffected — they keep the note-wide behaviour they were built with until you add a group.
  • Database Views have one too — the Has a Task Where ALL Of section of the filter editor, working exactly the same way. Like the rest of a view's filters, it's edited on macOS; iPhone and iPad honour it.

Negative task rules only consider notes that have tasks#

Task Project is not alpha means "the note has a task, and none of them is in alpha." A note with no tasks at all — a recipe, a journal entry, a reference page — is neither "in alpha" nor "not in alpha"; it's simply out of scope for a task question, so it's excluded from both the positive and the negative form.

This applies to every negative task operator: is not, does not contain, and is not under. (Positive operators are naturally fine — a note with no tasks can't match "has a task in alpha".)

Finding unassigned tasks — "is none"#

Use is none to find tasks that were never given a project or context:

  • Task Project is none — notes containing a task with no project (neither an inline project: token nor one inherited from the note's project tag).
  • Task Context is none — notes containing a task with no context.

These are the query equivalent of the Task Board's (No Project) / (No Context) filters. Because "is none" is a positive "has a task like this" question, task-less notes are correctly excluded.

A few useful queries

  • My inbox — a task group of Task Context is me and Task Completion is false: notes with an unfinished task assigned to you, wherever it lives. (As a group, so the two rules describe the same task.)
  • Triage pile — a task group of Task Context is none and Task Completion is false: things you've captured but not yet classified, and not yet done.
  • Client review — a task group of Task Project is under acme and Task Due date is this week: everything for a client, across its sub-projects, due soon — one task satisfying both, rather than a note that happens to have an acme task and, separately, something due this week.
  • Stale workHas tasks is true and Date modified not within last 30 days: notes with tasks you haven't touched in a month.

Running queries everywhere#

  • Sidebar — saved queries sync across your devices: build one anywhere and it's saved to the rest. (Database Views are the exception — their filter rules are edited on macOS only.)
  • Command linefn query run "<query name>" executes a saved query and prints the matching notes (--json for scripting). fn query list shows what's available.
  • AI integration — the MCP server exposes list_queries and run_query, so an assistant can run your saved queries too.

See also#

  • Database Views — the same query rules, shown as a sortable table with columns.
  • Tasks — task syntax, projects, and contexts.
  • Task Board — a live kanban of the same task data (macOS).