Last active
August 29, 2015 14:27
-
-
Save sonwh98/3f49b046ae5fd1355b10 to your computer and use it in GitHub Desktop.
the clojure datomic/datascript api functions require passing in the db as a value. this gets tedious. Wrap these functions to use the current db
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
(defn q [& params] | |
"wrapper around d/q so that you don't have to pass in the database everytime" | |
(let [query (first params) | |
query+conn (conj [query] | |
@db) | |
variable-bindings (rest params) | |
params2 (vec (concat query+conn variable-bindings))] | |
(apply d/q params2))) | |
(defn transact! [datoms] | |
"wrapper around d/transact! so that you don't have to pass in the database everytime" | |
(d/transact! db datoms)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment