For the simple cases of "all attribute and value pairs, sorted", using take with seek-datoms
is your best option. The following example uses the mbrainz sample database:
(def conn (d/connect "datomic:sql://mbrainz-1968-1973?jdbc:postgresql://localhost:5432/datomic?user=datomic&password=datomic"))
(->> (d/seek-datoms (d/db conn) :avet :artist/sortName "Bea")
(take 20))
and returns:
(#datom[17592186050196 81 "Beach Boys, The" 13194139539089 true]
#datom[17592186047857 81 "Beatles, The" 13194139536749 true]
#datom[17592186048553 81 "Beau Brummels, The" 13194139537425 true]
#datom[17592186049043 81 "Beaver & Krause" 13194139537919 true]
#datom[17592186046205 81 "Beaver, Paul" 13194139535085 true]
#datom[17592186046692 81 "Beck, Bogert & Appice" 13194139535579 true]
#datom[17592186046886 81 "Beck, Jeff" 13194139535761 true]
#datom[17592186047111 81 "Beck, Jeff Group" 13194139535995 true]
#datom[17592186046486 81 "Bedford, David" 13194139535371 true]
#datom[17592186046992 81 "Bee Gees" 13194139535865 true]
#datom[17592186045876 81 "Beethoven, Ludwig van" 13194139534747 true]
#datom[17592186048427 81 "Beggars Opera" 13194139537321 true]
#datom[17592186047091 81 "Beginning of the End, The" 13194139535969 true]
#datom[17592186045945 81 "Belafonte, Harry" 13194139534825 true]
#datom[17592186047485 81 "Bell, Archie & Drells, The" 13194139536359 true]
#datom[17592186045915 81 "Bell, Carey" 13194139534799 true]
#datom[17592186046324 81 "Bell, Vinnie" 13194139535215 true]
#datom[17592186047164 81 "Bell, William" 13194139536047 true]
#datom[17592186047652 81 "Belle, Marie-Paule" 13194139536541 true]
#datom[17592186046496 81 "Bellou, Sotiria" 13194139535371 true])
Of course, you can map a fn that prettifies the output or adds more attributes, etc. such as in this example:
(let [db (d/db conn)]
(->> (d/seek-datoms db :avet :artist/sortName "Bea")
(take 20)
(map #(merge {:artist/name (:v %)
:artist/type (-> (d/pull db [{:artist/type [:db/ident]}] (:e %))
:artist/type
:db/ident)}))))
Which returns:
({:artist/name "Beach Boys, The" :artist/type :artist.type/group}
{:artist/name "Beatles, The" :artist/type :artist.type/group}
{:artist/name "Beau Brummels, The" :artist/type :artist.type/group}
{:artist/name "Beaver & Krause" :artist/type :artist.type/group}
{:artist/name "Beaver, Paul" :artist/type :artist.type/person}
{:artist/name "Beck, Bogert & Appice" :artist/type :artist.type/group}
{:artist/name "Beck, Jeff" :artist/type :artist.type/person}
{:artist/name "Beck, Jeff Group" :artist/type :artist.type/group}
{:artist/name "Bedford, David" :artist/type :artist.type/person}
{:artist/name "Bee Gees" :artist/type :artist.type/group}
{:artist/name "Beethoven, Ludwig van" :artist/type :artist.type/person}
{:artist/name "Beggars Opera" :artist/type :artist.type/group}
{:artist/name "Beginning of the End, The" :artist/type :artist.type/group}
{:artist/name "Belafonte, Harry" :artist/type :artist.type/person}
{:artist/name "Bell, Archie & Drells, The" :artist/type :artist.type/group}
{:artist/name "Bell, Carey" :artist/type :artist.type/person}
{:artist/name "Bell, Vinnie" :artist/type :artist.type/person}
{:artist/name "Bell, William" :artist/type :artist.type/person}
{:artist/name "Belle, Marie-Paule" :artist/type :artist.type/person}
{:artist/name "Bellou, Sotiria" :artist/type :artist.type/person})
Note: to use seek-datoms
or datoms
with :avet
, the attribute in question must be indexed.