Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Another idea... Templated queries #76

Open
davecan opened this issue Apr 5, 2021 · 5 comments
Open

Another idea... Templated queries #76

davecan opened this issue Apr 5, 2021 · 5 comments
Assignees
Labels
DQL Query language UX, issues, and features. feature-request New feature or request.

Comments

@davecan
Copy link

davecan commented Apr 5, 2021

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 davecan changed the title Another idea... :) Templated queries Another idea... Templated queries Apr 5, 2021
@blacksmithgu
Copy link
Owner

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

@blacksmithgu blacksmithgu added the DQL Query language UX, issues, and features. label Apr 5, 2021
@blacksmithgu blacksmithgu self-assigned this Apr 5, 2021
@davecan
Copy link
Author

davecan commented Apr 6, 2021

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! ❤️

@blacksmithgu blacksmithgu added the feature-request New feature or request. label Apr 8, 2021
@AB1908
Copy link
Collaborator

AB1908 commented Jul 25, 2022

Hey there, what was the use case for this?

@Dave-Snigier
Copy link

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.

@AB1908
Copy link
Collaborator

AB1908 commented Aug 23, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DQL Query language UX, issues, and features. feature-request New feature or request.
Projects
None yet
Development

No branches or pull requests

4 participants