71bef46 ←14d948eantonApr 19, 2026 api

create dataview.md via macOS

A /docs/undefined +183 -0
A /docs/undefined +183 -0
1# Dataview
2
3sublimated renders [Obsidian Dataview](https://blacksmithgu.github.io/obsidian-dataview/) DQL queries as live tables and lists. no plugins needed — queries evaluate server-side when the page loads.
4
5## code block queries
6
7wrap DQL in a `dataview` fenced code block:
8
9````markdown
10```dataview
11TABLE date, purpose
12WHERE date
13SORT date DESC
14```
15````
16
17queries run against all files in the current folder. each file's YAML frontmatter fields are available as columns.
18
19## inline expressions
20
21use `` `= expr` `` anywhere in text or markdown tables for computed values:
22
23```markdown
24total files: `= length(rows)`
25countries: `= length(unique(filter(flat(rows.tags), (t) => startswith(t, "country/"))))`
26```
27
28inline expressions have access to `rows` — all sibling files in the current folder.
29
30## query types
31
32### TABLE
33
34```dataview
35TABLE date, purpose, length(tags) AS "Tags"
36WHERE date
37SORT date DESC
38LIMIT 10
39```
40
41renders as an HTML table. first column is always the file link.
42
43### LIST
44
45```dataview
46LIST purpose
47WHERE purpose
48SORT file.name
49```
50
51renders as a bullet list with file links.
52
53## operations
54
55operations apply in the order written:
56
57- `WHERE condition` — filter rows
58- `SORT field ASC|DESC` — sort rows (multiple fields supported)
59- `LIMIT n` — cap number of results
60- `FLATTEN field AS alias` — expand array fields into separate rows
61- `GROUP BY expr AS "Label"` — group rows, access group items via `rows` variable
62
63### GROUP BY
64
65groups all matching files by expression. each group becomes one row with `rows` containing the grouped items:
66
67```dataview
68TABLE length(rows) AS "Count"
69WHERE tags
70GROUP BY dateformat(date, "yyyy") AS "Year"
71SORT length(rows) DESC
72```
73
74access grouped data: `rows.file.name` gives array of file names in the group, `flat(rows.tags)` flattens all tags.
75
76### FLATTEN + GROUP BY
77
78combine FLATTEN and GROUP BY for disaggregation/reaggregation:
79
80```dataview
81TABLE length(rows) AS "Trips"
82FLATTEN filter(tags, (t) => startswith(t, "country/")) AS country
83WHERE country
84GROUP BY replace(country, "country/", "") AS "Country"
85SORT length(rows) DESC
86```
87
88this expands each file's country tags into separate rows, then groups by country name.
89
90## expressions
91
92### fields
93
94- `file.name` — filename without extension
95- `file.path` — full path
96- `file.folder` — parent folder
97- `file.size` — size in bytes
98- `file.ctime` — created time
99- `file.mtime` — modified time
100- `file.link` — link to the file
101- any frontmatter field — `date`, `tags`, `purpose`, etc
102
103### operators
104
105- comparison: `=`, `!=`, `>`, `<`, `>=`, `<=`
106- arithmetic: `+`, `-`, `*`, `/`, `%`
107- logical: `AND`, `OR`, `!`
108
109### lambdas
110
111```
112(x) => startswith(x, "country/")
113```
114
115used with `filter`, `map`, `sort`, `any`, `all`, `none`.
116
117## functions
118
119### array
120- `length(array)` — count elements
121- `contains(array, value)` — check membership
122- `filter(array, lambda)` — keep matching elements
123- `map(array, lambda)` — transform elements
124- `sort(array)` — sort elements
125- `unique(array)` — deduplicate
126- `flat(array)` — flatten one level of nesting
127- `join(array, separator)` — join to string
128- `reverse(array)` — reverse order
129- `any(array, lambda)` — true if any match
130- `all(array, lambda)` — true if all match
131- `none(array, lambda)` — true if none match
132
133### string
134- `contains(string, substring)` — check substring
135- `startswith(string, prefix)` — check prefix
136- `endswith(string, suffix)` — check suffix
137- `lower(string)`, `upper(string)` — case conversion
138- `replace(string, from, to)` — replace substring
139- `split(string, delimiter)` — split to array
140- `regextest(pattern, string)` — regex match test
141
142### date
143- `dateformat(date, format)` — format date (e.g. `"yyyy-MM-dd"`, `"yyyy"`)
144- `date(string)` — parse string to date
145- `striptime(date)` — remove time component
146
147### math
148- `round(n)`, `floor(n)`, `ceil(n)` — rounding
149- `min(array)`, `max(array)` — extremes
150- `sum(array)`, `average(array)` — aggregation
151
152### utility
153- `default(value, fallback)` — null coalescing
154- `choice(condition, ifTrue, ifFalse)` — ternary
155- `typeof(value)` — type name
156- `string(value)`, `number(value)` — type conversion
157- `link(path, display)` — create link
158
159## frontmatter
160
161YAML frontmatter is automatically extracted and stored when files are pushed. string values that look like dates (`YYYY-MM-DD`) are parsed as date objects.
162
163```yaml
164---
165title: Japan 2024
166date: 2024-03-15
167purpose: tourism
168tags:
169 - country/japan
170 - city/tokyo
171 - city/kyoto
172---
173```
174
175all fields are accessible in queries: `WHERE date > date("2024-01-01")`, `SORT date DESC`, etc.
176
177## limitations
178
179- queries only access files in the current folder (no cross-folder queries yet)
180- no FROM clause needed — defaults to current folder
181- `FROM "subfolder"` resolves relative to the current folder
182- TASK and CALENDAR query types not supported
183- no custom JS views