Return Maps

18 May 2019

Most Datomic queries return tuples, but sometimes you just want maps.  Today's release of the Datomic Cloud client library adds return maps to Datomic datalog.  For example, the following query uses the new :keys clause to request maps with :artist and :release keys:

[:find ?artist-name ?release-name
:keys artist release
:where [?release :release/name ?release-name]
[?release :release/artists ?artist]
[?artist :artist/name ?artist-name]]

Running against the mbrainz-sample database, this query returns:

#{{:artist "George Jones" :release "With Love"}
{:artist "Shocking Blue" :release "Hello Darkness / Pickin' Tomatoes"}
{:artist "Junipher Greene" :release "Friendship"}

To try return maps, you can