obsidian-dataview icon indicating copy to clipboard operation
obsidian-dataview copied to clipboard

Another idea... Templated queries

Open davecan opened this issue 3 years ago • 5 comments

Concept syntax:

```dataview(template="my-query", args=["arg1", "val1", "arg2", "[[val2]]", ...])
```

Config screen then has a section to select a template folder. template is the name of the note in the template folder. That note can contain anything (for descriptive comments, etc) but only the actual query itself is extracted from the template at runtime and executed in the target note. Using named params instead of positional params keeps the calling syntax extensible.

There are certainly other ways to do it as well, this is just a thought.

davecan avatar Apr 05 '21 11:04 davecan

Yeah, seems useful for common queries like "show all the daily notes for month <X>" or "create a generic index over files tagged #thing". Will see what I can do.

blacksmithgu avatar Apr 05 '21 21:04 blacksmithgu

Yep! This would be especially powerful in combination with your existing idea to have a this variable that can pull data from the note containing the query.

Thanks, you are awesome! :heart:

davecan avatar Apr 06 '21 01:04 davecan

Hey there, what was the use case for this?

AB1908 avatar Jul 25 '22 12:07 AB1908

Hi @AB1908 I'm not OP, but I'll provide a few use cases based on my usage.

There are a few queries I include in all notes of a certain type. For instance, contact notes contain queries to get all the projects a person is a part of and which meetings they've attended. If I could reference a named query in my contacts note template, all current and future contact notes would contain the latest query when I make changes (DRY). Writing regex find/replace to update all query instances is painful at the moment and needlessly updates the file modification time of the notes.

Not something I'm using yet, but the inline syntax seems really powerful. Its compact nature I think would lend itself well to some sort of "stored procedure" as well.

Dave-Snigier avatar Aug 23 '22 12:08 Dave-Snigier

This seems doable via dv.view() at the moment but it's a decent idea.

AB1908 avatar Aug 23 '22 13:08 AB1908