在其历史记录中查询 datomic db 实体的所有属性的正确方法是什么?
例如,通过查询中的拉取 API 或拉取表达式,可以使用通配符打印给定实体的所有属性。但是,相同的方法不适用于特殊历史数据库。
(d/q '[:find [(pull ?e [*]) ...] :where [?e :test/firstName "Bob"]] db-test)
; outputs list of Bob's properties
(d/q '[:find [(pull ?e [*]) ...] :where [?e :test/firstName "Bob"]] (d/history db-test))
; IllegalStateException Can't pull from history
Run Code Online (Sandbox Code Playgroud)
您可以使用查询为所有历史记录返回单个实体的所有数据:
(d/q '[:find ?e ?a ?v ?t ?op
:in $ ?e
:where [?e ?a ?v ?t ?op]]
(d/history (d/db conn)) <Your Entity ID>)
Run Code Online (Sandbox Code Playgroud)