DQL Syntax Reference
Complete formal syntax and clause reference for Basalt's Dataview Query Language engine.
Query Headers
TABLE
TABLE [WITHOUT ID] [expr [AS "Column Name"]], ...
- Emits a structured tabular grid.
- By default, includes
file.nameas the first column link. UseWITHOUT IDto suppress the automatic note column.
LIST
LIST [expr]
- Emits an unordered list of notes with optional computed text appended.
TASK
TASK
- Collects and renders checklist tasks embedded in notes matching the source and filter conditions.
Clauses
FROM
Specifies the initial universe of notes to include.
| Source Expression | Meaning |
|---|---|
"" | All notes in the vault |
#tag | Notes containing #tag or nested #tag/* |
"Folder" | Notes located inside Folder/ |
[[Note Title]] | Notes linking to [[Note Title]] |
outgoing([[Note Title]]) | Notes linked from [[Note Title]] |
Boolean Combinations:
Sources can be combined with AND, OR, NOT, and parentheses:
FROM (#work OR #freelance) AND !"Archive"
WHERE
Filters candidate rows by boolean predicates:
WHERE status = "in-progress" AND priority > 1
FLATTEN
Unrolls an array into individual rows or binds a computed expression:
FLATTEN tags AS tag
FLATTEN length(file.inlinks) AS backlink_count
GROUP BY
Partitions rows by field values into aggregate groups:
GROUP BY category
GROUP BY file.folder
Note: In grouped queries, note values are accessible via the rows collection (e.g. rows.file.name).
SORT
Orders rows by one or more expressions:
SORT file.mtime DESC, rating ASC
- Default direction is
ASC(ascending). - Null values sort lowest in ascending order.
LIMIT
Truncates output to at most n rows:
LIMIT 25
Expressions & Operators
Operators
| Operator | Type | Description |
|---|---|---|
=, != | Equality | Strict equality / inequality |
<, <=, >, >= | Relational | Comparison across typed values |
AND, OR | Logical | Logical conjunction and disjunction |
NOT, ! | Logical | Logical negation |
+, - | Arithmetic | Numeric addition / string concatenation |
Built-in Functions
| Function | Signature | Description |
|---|---|---|
contains | contains(haystack, needle) | Returns true if needle is in string or array |
length | length(x) | Returns array length or string character count |
Aggregate Functions (GROUP BY context only)
| Function | Signature | Description |
|---|---|---|
count | count(rows) | Total rows in current group |
length | length(rows) | Synonym for count(rows) |
sum | sum(rows.<field>) | Numeric sum of field across group |
avg / average | avg(rows.<field>) | Arithmetic mean |
min | min(rows.<field>) | Minimum value |
max | max(rows.<field>) | Maximum value |
Standard Note Properties (file.*)
Every note row exposes these metadata fields:
| Field | Type | Description |
|---|---|---|
file.name | string | File name without .md extension |
file.path | string | Full path relative to vault root |
file.folder | string | Directory containing the file |
file.size | number | Size in bytes |
file.ctime | date | Creation timestamp |
file.mtime | date | Last modified timestamp |
file.tags | array | All tags in frontmatter and body |
file.outlinks | array | Links originating from this note |
file.inlinks | array | Backlinks referencing this note |
file.tasks | array | Embedded checklist tasks |