This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-09-22
Channels
- # announcements (11)
- # architecture (7)
- # babashka (26)
- # beginners (314)
- # calva (20)
- # chlorine-clover (1)
- # cider (5)
- # circleci (27)
- # clara (6)
- # clj-kondo (41)
- # cljsrn (6)
- # clojure (120)
- # clojure-berlin (2)
- # clojure-czech (2)
- # clojure-dev (4)
- # clojure-europe (45)
- # clojure-france (4)
- # clojure-germany (1)
- # clojure-nl (5)
- # clojure-uk (20)
- # clojuredesign-podcast (8)
- # clojurescript (6)
- # conjure (42)
- # datascript (5)
- # datomic (21)
- # deps-new (28)
- # duct (1)
- # fulcro (36)
- # graalvm (10)
- # graphql (24)
- # jackdaw (19)
- # jobs (2)
- # jobs-discuss (46)
- # kaocha (6)
- # malli (26)
- # off-topic (21)
- # parinfer (5)
- # re-frame (10)
- # sci (19)
- # shadow-cljs (95)
- # tools-deps (24)
- # vim (3)
Hello folks. How do I group results in Datascript query? Is there a faster way than "query the whole result set, then group-by
"?
@misha470 guess it depends what you mean but datalog does have aggregates for grouping http://www.learndatalogtoday.org/chapter/7
@oliver.marks I mean something like the following: "query all entities, grouped by :entity/bar
and :entity/baz
" -> {[:a :b] [{:entity/name "xxx" :entity/bar :a :entity/baz :b} {:entity/name "yyy" :entity/bar :a :entity/baz :b}] [:a :d] [{:entity/name "zzz" :entity/bar :a :entity/baz :d}] [:c :e] [{:entity/name "qqq" :entity/bar :c :entity/baz :e} {:entity/name "www" :entity/bar :c :entity/baz :e}]}
"all entities" will vary, of course.
Though it looks like there is no point doing it in Datascript: clojure.core/group-by
is just fine.