Last active
August 29, 2015 14:12
-
-
Save aamedina/a1ca5e97c1a5d73fe141 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is nice.