Hey! Why does index-range only support :avet? I have a :db.cardinality/many :occurrences that are instants and I want to get the instants that fall in a range for an entity. I can use seek-datoms with :eavt and then use take-while to ensure that I only consume while it's still the desired entity and attribute. index-range seems like the more appropriate function. It would be perfect if I wanted all :occurrences inside of a range but I only want to query for one entity.
I see that both index-range and seek-datoms call slice under the hood. So, it indexes the b-tree to get the starting datom and walks from there.
This is what I'm doing with take-while .
Well. I guess one answer is that that's how datomic works. https://docs.datomic.com/client-api/datomic.client.api.html#var-index-range
Yes
Nobody asked for ranges inside one attribute so far, so
I would’ve cached eid, but other that that, it should work
(let [eid (:db/id (ds/entity (get-ds-db) [:title title]))]
(->>
(ds/seek-datoms (get-ds-db) :eavt eid :occurrences (jt.instant/minus-seconds now 5))
(take-while
#(and
(= eid (:e %))
(= :occurrences (:a %))))
(mapv :v)))
TBH even with index-range, I used it probably once, so not sure how popular those are
Ok thanks. I’ll keep going with this since it works. If I’m up for some fun then I’ll look at using slice. Thanks again!