엔티티와 타임 스탬프에 관심이 있습니다. 기본적으로 엔티티의 시간순으로 정렬 된 목록이 필요합니다. 이를 위해Datomic에서 가장 최근 엔티티 검색
, 나는 다음과 같은 기능을 구성했습니다 : 나는 이 무지에 뿌리를 해킹해야 기분이
(defn return-posts
"grabs all posts from Datomic"
[]
(d/q '[:find ?title ?body ?slug
:where
[?e :post/title ?title]
[?e :post/slug ?slug]
[?e :post/body ?body]] (d/db connection)))
(defn get-postid-from-slug
[slug]
(d/q '[:find ?e
:in $ ?slug
:where [?e :post/slug ?slug]] (d/db connection) slug))
(defn get-post-timestamp
"given an entid, returns the most recent timestamp"
[entid]
(->
(d/q '[:find ?ts
:in $ ?e
:where
[?e _ _ _]
[?e :db/txInstant ?ts]] (d/db connection) entid)
(sort)
(reverse)
(first)))
.
관용적 인 Datomic 사용에 익숙한 사람이 내 패러다임을 선택하고 업그레이드합니까?
AFAIK는 게시물/제목이 엔티티에 대해 어설 션되었으며 엔티티가 마지막으로 거래의 주제가 아닌 순간의 현재 값을 제공한다는 점에 유의할 가치가 있습니다. – spieden