Skip to content

Instantly share code, notes, and snippets.

@souenzzo

souenzzo/foo.clj Secret

Created February 3, 2022 11:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save souenzzo/eb3753302d5af047346ac1c510500e69 to your computer and use it in GitHub Desktop.
Save souenzzo/eb3753302d5af047346ac1c510500e69 to your computer and use it in GitHub Desktop.
(require '[datomic.client.api :as d])
(let [conn (-> {:server-type :dev-local
:system "hello"}
d/client
(doto (d/delete-database {:db-name "hello"})
(d/create-database {:db-name "hello"}))
(d/connect {:db-name "hello"}))
do-tx! (fn [s] (-> conn
(d/transact {:tx-data [{:db/ident :hello
:db/doc s}
{:db/id "datomic.tx"
:db/doc s}]})
:tempids
(get "datomic.tx")))
q! (fn [t]
(first (d/q '[:find ?doc :where [?e :db/ident :hello] [?e :db/doc ?doc]]
(d/as-of (d/db conn) t))))
first-tx (do-tx! "first one")
second-tx (do-tx! "second one")
last-tx (do-tx! "last one")]
(q! last-tx)
(q! (dec last-tx)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment