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.