DEV Community

Sub Engel
Sub Engel

Posted on

Dataview queries I'd put in any developer vault (and the gotchas that break them)

A few days ago I posted Dataview queries worth having in a developer vault. The comments were better than the post. They pointed out three things that quietly break these queries.

This is the follow-up. Different queries, and the fixes baked in.

Same disclaimer as last time: Dataview only reads the Markdown notes in your vault. It doesn't read your code. It's for the notes about your code.

The three gotchas first

Cancelled tasks count as open. Dataview only treats [x] as completed. So !completed also matches [-], which is how the Tasks plugin (and many themes) mark cancelled tasks. Add status != "-". status is the character between the brackets.

While you're there, add text != "". Templates leave empty checkboxes behind, and they show up as open tasks too.

Sync bumps file.mtime. file.mtime is the time on disk. Obsidian Sync, iCloud and Syncthing can change it when they write a note to another device. So "recently modified" fills up with notes you didn't touch. The fix is a modified: field in frontmatter, with file.mtime as a fallback.

Orphan lists fill up with templates. Templates, daily notes and dashboards are unlinked on purpose. If you leave them in, the real orphans get buried. Excluding folders by name works until you rename a folder. A frontmatter flag doesn't have that problem.

Now the queries. Folder names are mine (Projects, Templates). Change the text after FROM to match yours.

1. Open tasks across the whole vault

Every unchecked task outside the templates folder, grouped by note. No fields needed, just checkboxes.

TASK
FROM -"Templates"
WHERE !completed AND status != "-" AND text != ""
GROUP BY file.link
Enter fullscreen mode Exit fullscreen mode

That's all three task filters in one line.

2. Recently modified notes, sync-safe

Notes edited in the last 7 days, newest first.

TABLE file.folder AS "Folder", default(modified, file.mtime) AS "Modified"
FROM -"Templates"
WHERE default(modified, file.mtime) >= date(today) - dur(7 days) AND file.path != this.file.path
SORT min(default(modified, file.mtime), date(now) - dur(5 minutes)) DESC, file.name ASC
Enter fullscreen mode Exit fullscreen mode

Two things going on here.

default(modified, file.mtime) uses your modified: field when a note has one. Older notes fall back to the file time.

The min(...) in the sort is a grace window. Anything edited in the last 5 minutes sorts as "5 minutes ago". So when a sync lands mid-read, the list doesn't reshuffle under you. (That idea came from a commenter on the last post.)

To fill modified: automatically, the Linter plugin's "YAML timestamp" rule works. Set the key to modified, the format to YYYY-MM-DDTHH:mm:ss, and "Date modified source of truth" to "user or Linter edits". The default source copies the file time, which is the thing sync bumps.

3. Orphan notes, with an opt-out flag

Notes nothing links to, newest first.

LIST
FROM -"Templates"
WHERE length(file.inlinks) = 0 AND exclude-from-orphans != true
SORT file.ctime DESC
Enter fullscreen mode Exit fullscreen mode

Put exclude-from-orphans: true in the frontmatter of anything that's unlinked on purpose. Daily notes, dashboards, the note holding this query. Put it in your daily note template once and you're done.

Note this only checks inlinks. A note that links out but nothing links to is still hard to find again. That's the one I want to see.

4. Stale projects

Projects still marked active that nobody has touched in 30 days, oldest first.

TABLE default(modified, file.mtime) AS "Last edited", length(filter(file.tasks, (t) => !t.completed AND t.status != "-" AND t.text != "")) AS "Open tasks"
FROM "Projects"
WHERE type = "project" AND status = "active" AND default(modified, file.mtime) < date(today) - dur(30 days)
SORT default(modified, file.mtime) ASC
Enter fullscreen mode Exit fullscreen mode

Expects type: project and status: active in frontmatter. Same modified: fallback as above, otherwise a sync makes every project look fresh.

The open task count comes from the checkboxes in the note. No counter field to keep in sync by hand.

When something shows up here, either pick it back up or change its status. "Active" should mean active.

If a query shows nothing

  • Dates in frontmatter need to be plain ISO (2026-09-27). Sept 27 is just text, and date comparisons silently return nothing.
  • Field names get normalized. Due Date becomes due-date.
  • Strip the query down to LIST FROM "Folder" and add clauses back one at a time. Usually it's the folder name.

The rest

I put all 10 in one note: these four, plus unfinished tasks from recent daily notes, an ADR log, ADRs due for review, active projects with open task counts, incident follow-ups and a tech debt register. Each one says what it shows and which fields it expects. It's free (pay what you want): https://subengel.gumroad.com/l/dzanl

If you'd rather start from a whole vault with the templates and dashboards already set up, that's Dev Second Brain.

Top comments (0)