Skip to content

Instantly share code, notes, and snippets.

@aamedina
Last active August 29, 2015 14:12
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 aamedina/a1ca5e97c1a5d73fe141 to your computer and use it in GitHub Desktop.
Save aamedina/a1ca5e97c1a5d73fe141 to your computer and use it in GitHub Desktop.
(require '[datomic.api :as api :refer :all :exclude [filter sync]]
'[com.stuartsierra.component :as c])
(defrecord Database [uri conn]
c/Lifecycle
(start [this]
(create-database uri)
(if conn
this
(assoc this :conn (connect uri))))
(stop [this]
(if conn
(assoc this :conn nil)
this))
clojure.lang.IDeref
(deref [this] (db conn)))
(prefer-method print-method clojure.lang.IRecord clojure.lang.IDeref)
@eslick
Copy link

eslick commented Jan 5, 2015

This is nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment