Read my blog about Roam Query.
This will only work if you have Roam42 installed.
Shift click on Template/Datomic Query and start the roam/js script under Common functions. You only need to do this only once.
Choose between two methods to run a query:
simple-query: If you do not want to pass parameters to the query and you do not want any javascript post-processing, use the simple-query.
advanced-query: The advanced query provides you with full flexibility. But looks a bit more messy.
To generate the template for your query run the appropriate Roam42 SmartBlock:
Datomic simple-template
Datomic advanced-template
I have added very basic (and limited) post processing of the result.
Results are displayed in a single block using ::hiccup. This is to avoid filling your graph with unnecessary number of blocks.
Displaying Page Titles and Dates as links
At the moment these only work outside of (pull ) statements, and outside of aggregate functions.
I convert Page Titles into page links.
Designate the title filed by adding :name to the field name
?title:name
Designate the corresponding uid by:
placing the uid immediately after the ?title:name field
and adding :uid to the field name
?title:uid
I convert dates to Daily Notes links.
Designate a field to be converted by adding :date to it
?edit:date or ?create:date
Displaying nested results as a table in the table in the table...
When executing a query that includes a (pull ) statement the result will be a tree, not a table. Technically speaking the result is a JSON data structure.
I render query results according to the following logic
The top level of the result-set is displayed as rows of a table, with values as the columns.
Nested levels in the result-set alternate between being rendered in columns or rows.
At nested levels I use MAXROWS/4 to limit the number of rows to display. Even with this the final result set could reach thousands of rows.
MAXROWS is set to 40 by default. In the advanced-query you can change this number.
Execute your query by pressing the button nested under the query.
If you find this helpful 🙏 say thanks on Twitter @zsviczian. If you like it even more, ☕ Buy me a Coffee as a show of your appreciation.