This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-08-27
Channels
- # admin-announcements (1)
- # announcements (11)
- # babashka (17)
- # beginners (26)
- # calva (6)
- # cider (2)
- # circleci (1)
- # clojure (41)
- # clojure-dev (1)
- # clojure-europe (31)
- # clojure-france (2)
- # clojure-italy (10)
- # clojure-nl (7)
- # clojure-norway (5)
- # clojure-spec (15)
- # clojure-uk (42)
- # clojurescript (4)
- # code-reviews (12)
- # conjure (10)
- # datalog (2)
- # datascript (15)
- # datomic (37)
- # emacs (1)
- # events (5)
- # fulcro (19)
- # jobs (1)
- # jobs-discuss (9)
- # kaocha (2)
- # luminus (14)
- # meander (4)
- # membrane (39)
- # off-topic (26)
- # other-languages (2)
- # re-frame (13)
- # reitit (6)
- # rewrite-clj (39)
- # sci (6)
- # shadow-cljs (33)
- # test-check (15)
- # vrac (17)
- # xtdb (7)
Got another question with d/q if you query a product which has many prices related to an entity can you get a list with in a list response or would I be doing 2 queries to achieve this ?
so would I query for the products retrieve the entity ids to then query for the related prices or is there a way to do this in a single query ?
@oliver.marks - I think your last two questions are essentially the same; I usually approach them like this: use q
to query, use pull
to pull.
1. Find the subset of eids that match my expectation via q
(or even multiple q
)
2. Then forget about querying and use pull
(either as (pull ..)
inside q, or via d/pull
or d/pull-many
) to fetch everything I'm actually interested.
3. Then, use clojure for data munging if my pull result does not line up with my expected output.
yeah I just went and looked at the previous message after noticing it had replies, I wonder if you can change that so it does not thread
but I am having a read through and thanks for the detailed responses hopefully it will help direct me in the right direction
@pithyless just realised it was your youtube video I watched which got me interested in datalog great work 🙂

Yea, it's a great video. The visualizations/slides were very well done. Must have been tons of work doing the highlighting. What did you use to create it?
making some headway
(->> (d/q
'[:find ?e
:where
[?e :product/id ?product-id]
[?e :product/name ?product-name]]
(d/db conn))
(map (fn [eid]
(d/pull
(d/db conn)
'[* :price/_product]
(first eid)))))
This seems to return all the prices under the :price/_product key can i extend that to be the price eid and amount or will i need to map again to pull the extra details ?okay think i am getting there the discovery of _product has helped.
(d/q
'[:find (pull ?e [* {:price/_product [:price/amount]}])
:where
[?e :product/id ?product-id]]
(d/db conn))
that is nearing what I want I believe i need to just flatten out the result now so i can make a csv