This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-07-13
Channels
- # aleph (15)
- # announcements (4)
- # babashka (36)
- # babashka-sci-dev (1)
- # beginners (15)
- # biff (2)
- # calva (15)
- # cider (3)
- # clj-kondo (8)
- # clojure (149)
- # clojure-europe (14)
- # clojure-norway (13)
- # clojure-switzerland (1)
- # clojure-uk (1)
- # clojurescript (21)
- # community-development (5)
- # cursive (20)
- # data-science (2)
- # datomic (7)
- # duct (5)
- # emacs (19)
- # etaoin (3)
- # events (2)
- # fulcro (11)
- # introduce-yourself (2)
- # jobs (4)
- # jobs-discuss (19)
- # joyride (1)
- # leiningen (11)
- # malli (7)
- # membrane (131)
- # nbb (12)
- # nginx (1)
- # off-topic (33)
- # pathom (8)
- # polylith (28)
- # re-frame (8)
- # sci (7)
- # shadow-cljs (225)
- # spacemacs (10)
- # specter (1)
- # vim (10)
- # xtdb (8)
What would be a proper way to return names, like in query below but for all :clan/id
's in the database grouped by :clan/id
?
Expected result {"cid-1" [names], "cid-2" [names]}
'{:find [name]
:where [[c :clan/id "cid-1"]
[c :clan/members p]
[p :profile/name name]]}
I thought you could just do:
'{:find [name]
:where [[c :clan/id ]
[c :clan/members p]
[p :profile/name name]]}
Does that not work?i obviously could do :find [c name]
and group by first
but i'm interested if that possible to do as a query
Hey @UH16CGZC2 perhaps this?
'{:find [(distinct c) name]
:where [[c :clan/id]
[c :clan/members p]
[p :profile/name name]]}
clan/id is already distinct natural id, not sure how that helps, for now i did it that way
(comment ;; clan member names grouped by clan/id
(->> (q '{:find [c name]
:where [[c :clan/id]
[c :clan/members p]
[p :profile/name name]]})
(group-by first)
(map #(do [(first %) (mapv second (second %))])))) ;; mapv extracts p/name from [c/id p/name] pairs.
Btw Jeremy i've watched your workshop from re:Clojure, great stuff, was really helpful.🙏 1