what is the best way to check if an attribute exists? (it is avet indexed)
That would depend on the database I suppose.
(d/q [:find ?e :where [?e :my/attribute _]] db) ? Maybe direct index access is faster!? (index-pull)
👍
I happened to have a need for this today and came up with
(defn has-attr? [db eid attr]
(-> db
^Iterable (d/datoms :eavt eid attr)
.iterator
.hasNext))
very datomic-peer specific, but I can't imagine it getting much faster.for datalevin I found there is d/eid . My use case was checking if an indexed entity exists