It would be nice to make advanced queries or their parts reusable in Logseq.
Having that, you don’t need to type them multiple times (adhoc-queries, multiple locations in graph) and can omit redundant query code.
According to learndatalogtoday.org,
rules are an easy way to do that:
You can abstract away reusable parts of your queries into rules, give them meaningful names and forget about the implementation details, just like you can with functions in your favorite programming language.
So what about adding a additional
:query/rules entry to
config.edn, similar to existent
:query/result-transforms for pre-defined
:result-transform functions? Then auto-include these to be usable in every advanced query.
Not so well-working alternatives:
- templates - still redundant, as they are just like copy/pasted text; can get ugly for bigger queries
- macro/command - didn’t work for me, seems to be not suited well for code incl. format/quoting etc.
Together with Add :pages to :default-queries in config this could make a powerful and flexible query system.