This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-05-26
Channels
- # announcements (7)
- # babashka (42)
- # beginners (349)
- # chlorine-clover (9)
- # cider (16)
- # circleci (2)
- # clj-kondo (6)
- # cljs-dev (61)
- # cljsrn (15)
- # clojure (95)
- # clojure-europe (11)
- # clojure-italy (2)
- # clojure-nl (4)
- # clojure-spec (4)
- # clojure-uk (24)
- # clojurescript (21)
- # conjure (2)
- # core-async (8)
- # cursive (12)
- # datascript (2)
- # emacs (4)
- # exercism (1)
- # figwheel-main (86)
- # fulcro (27)
- # graalvm (4)
- # helix (36)
- # hoplon (3)
- # interop (44)
- # kaocha (6)
- # lein-figwheel (4)
- # malli (7)
- # meander (9)
- # off-topic (95)
- # pathom (33)
- # pedestal (13)
- # re-frame (20)
- # reitit (3)
- # shadow-cljs (102)
- # tools-deps (14)
- # xtdb (16)
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
:where
[?id :block/included true]]
@conn))]
(let [content (first (first (vec (ds/q '[:find ?content
:where
[?included-block-ds-id :block/content ?content]]
@conn))))]
(ds/transact! conn [[:db/add (first included-block-ds-id)
:block/hiccup (block-content->hiccup
conn
content)]])))
This was resolved over here (tl;dr I was calling one of my own functions with the parameters reversed) https://stackoverflow.com/questions/62032169/in-datascript-how-can-i-create-a-new-attribute-from-the-value-of-another/62049029