Fork me on GitHub
#datomic
<
2020-07-15
>
Will19:07:30

Is there a way to access the entity id of the entity which a pull pattern is operating on? For example I'd like to get back ?e in addition to the value of :entity/attr2

(d/qseq {:query '[:find (pull ?e [:entity/attr2])
                  :where
                  [?e :entity/attr1 "Attr1Value"]]
         :args [(d/db conn)]})
I need to stream the results set into memory since there are millions of these entities in our database and they may not all fit in memory at once. I would use the datoms API but the query is asking for the entity id and value of all the :entity/attr2 datoms that have the value "Attr1Value" for :entity/attr1. It seems like the datoms API is more geared towards operating on a single attribute. I'm hoping qseq will allow me to express this logic while also streaming the results, I just need access to ?e. Anyone have any thoughts?

favila19:07:23

something wrong with (pull ?e [:db/id :entity/attr2]) ?

Will19:07:37

nope, that totally does it, thank you!