Skip to content

Instantly share code, notes, and snippets.

@sonwh98
Last active August 29, 2015 14:27
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 sonwh98/3f49b046ae5fd1355b10 to your computer and use it in GitHub Desktop.
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
(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