Fork me on GitHub
#datomic
<
2018-02-04
>
didiercrunch19:02:17

Is there a way to do a "group by" in datomic? Let say I have a music database with three columns in the schema: song-title artist-name and release-date. Is it possible to get the latest song-title released by each artist-name in a single query?

donmullen19:02:08

@didiercrunch if your schema uses references, then pull with map specifications would do what you want : https://docs.datomic.com/on-prem/pull.html#map-specifications

didiercrunch19:02:01

thanks, let me check that!

didiercrunch19:02:23

nevertheless, it is a bit strange there are no way to do grouping as a query... Maybe I need to change more my minds.

jeff.terrell20:02:58

@didiercrunch - You may be able to do this with the :with clause in the query API. I don't understand it well enough to know for sure though. https://docs.datomic.com/on-prem/query.html#with If that doesn't work, I would probably just pull all the data and do a manual clojure.core/group-by on the results. Although if you're not using Datomic on-prem, that might not work so well…

didiercrunch21:02:38

that was my first approach. But I fell it is not idiomatic. I need very fast queries too