Fork me on GitHub
Thomas Lisankie21:05:50

Trying to create a new attribute where the value is the result of a transformation on a different attribute for the same entity. So, say I have a database where every entity has attribute :content. I want to have an additional attribute for every entity called :transformed whose value is the result of applying function f to :content. How would I go about this idiomatically and efficiently? Currently trying to do this by performing a transaction and assigning the value of the new attribute to the value of the function applied to a query for the value of the original attribute for that entity. If it's not obvious, I'm fairly new to Datalog and Datascript

(doseq [included-block-ds-id (vec (ds/q '[:find ?id
                                          [?id :block/included true]]
  (let [content (first (first (vec (ds/q '[:find ?content
                                           [?included-block-ds-id :block/content ?content]]
    (ds/transact! conn [[:db/add (first included-block-ds-id)
                         :block/hiccup (block-content->hiccup

Thomas Lisankie19:05:22

This was resolved over here (tl;dr I was calling one of my own functions with the parameters reversed)