title: Retrieve Most Recent Entity from Datomic
body: <p>I'm interested in entities and their timestamps. Essentially, I want a time-sorted list of entities.</p>
  
  <p>To that end, I've composed the following functions:</p>
  
  <pre><code>(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]
    (-&gt;
     (d/q '[:find ?ts
            :in $ ?e
            :where
            [?e _ _ _]
            [?e :db/txInstant ?ts]] (d/db connection) entid)
     (sort)
     (reverse)
     (first)))
  </code></pre>
  
  <p>Which I feel <em>must</em> be a hack rooted in ignorance.</p>
  
  <p>Would someone more well-versed in idiomatic Datomic usage chime in and upgrade my paradigms?</p>