Ad-hoc querying in Datomic
jbnv opened this issue · 2 comments
jbnv commented
I didn't see anything about writing and running Datomic queries from smartblocks. Zsolt Viczián did a pretty good job with his smartblocks for Datomic queries. I think it would be helpful to include them in an extension specifically for building and running ad-hoc queries. I feel like this functionality is still a bit too DIY and having an extension would help prevent a lot of frustration in both learning how to use Datomic queries and in developing useful queries.
https://www.zsolt.blog/2021/01/Roam-Data-Structure-Query.html
Once I finish work for the day I can compose a proposed feature set.
jbnv commented
SmartBlocks
- QUERY or Q
- Take a query from the argument and put it in the block as a
:q
command. - Argument can be a literal Datomic query or a block reference to a
closure
code block. - Examples of use
<%Q:[:find (count ?title) :where [_ :node/title ?title]]%>
<%Q:XxXxXxXxX%>
- Take a query from the argument and put it in the block as a
- PULL or P
- Execute the pull command on the block specified by the argument.
- Examples of use
<%P:XxXxXxXxX%>
(runs[*]
)<%P:XxXxXxXxX,[:block/string]%>
- QUERYTOSCALAR or QS
- Run the included query and have it return a scalar inline.
- A "refresh" argument could, if set to true, produce a refresh icon 🔄 and an artifact to refresh the query.
- QUERYTOATTRIBUTES or QA
- Run the included query and have it return a single row of data expressed as a series of blocks of attributes with values.
- "Refresh" argument as described above.
- QUERYTOTABLE or QT
- Run the included query and have it return a table of results in hiccup.
- Basically what Zsolt's "simple query" script does, but without having the query present as a code block and having the results underneath the query block.
- "Refresh" argument as described above.
- QUERYINJAVASCRIPT or QJ
- Basically the JAVASCRIPT tag extended with Zsolt's "advanced query" script functionality.
dvargas92495 commented
Moved to Smartblocks repo