datahike

cjohansen 2026-04-19T08:59:55.728609Z

Hi 👋 I'm working on adding Datahike support to #dataspex. One of the things its datalog browser does is to browse all entities. What's a good way to find all entities (excluding transactions and attributes) in a Datahike database?

1
whilo 2026-04-21T09:40:52.361829Z

clojure
(require '[datahike.api :as d]
         '[datahike.constants :as const])

(->> (d/q '[:find [?e ...]
            :in $ ?tx0
            :where
            [?e _ _]
            [(< ?e ?tx0)]
            (not [?e :db/ident _])]
          db const/tx0)
     (map #(d/entity db %)))
This excludes: - transaction entities via (< ?e tx0) - attribute/schema entities via (not [?e :db/ident _]) I tested the same query in both :attribute-refs? true and :attribute-refs? false, and it returned only the domain entities in both cases. One small note: if you want stable ordering, sort the resulting eids before mapping them to entities.

cjohansen 2026-04-21T09:50:06.355249Z

Cool, thanks 🙏

cjohansen 2026-04-19T09:00:25.710889Z

For Datomic I do this:

(def last-tx (d/t->tx 0x00000000FFFFFFFF))

(->> (d/seek-datoms db :eavt last-tx)
     (map :e)
     distinct
     (map #(d/entity db %)))
These APIs are available in Datahike as well, but I'm not sure how to make it skip past the transactions.

cjohansen 2026-04-19T09:01:10.601779Z

I assume a naive remove would be quite slow on large databases(?)

cjohansen 2026-04-19T09:13:53.953679Z

Another question: Datomic has (d/db-stats (d/db conn)) for quick stats about number of datoms etc. Is there something similar in Datahike?

whilo 2026-04-21T09:42:44.705079Z

Not yet, but we have d/metrics. If this is insufficient feel free to open an issue. PRs are also welcome.

cjohansen 2026-04-21T09:49:34.182649Z

Cool, I'll check it out 👍