Merge pull request #69 from seancorfield/master

Use local binding instead of dynamic global for collection. Fixes #68
This commit is contained in:
Michael Klishin 2014-01-12 00:38:56 -08:00
commit c2a13a1645

View file

@ -26,8 +26,6 @@
;; Implementation ;; Implementation
;; ;;
(def ^{:dynamic true} *query-collection*)
;; ;;
;; Cursor/chain methods ;; Cursor/chain methods
;; ;;
@ -135,11 +133,12 @@
(defmacro with-collection (defmacro with-collection
[^String coll & body] [^String coll & body]
`(binding [*query-collection* (if (string? ~coll) `(let [coll# ~coll
(.getCollection ^DB monger.core/*mongodb-database* ~coll) db-coll# (if (string? coll#)
~coll)] (.getCollection ^DB monger.core/*mongodb-database* ^String coll#)
(let [query# (-> (empty-query *query-collection*) ~@body)] coll#)
(exec query#)))) query# (-> (empty-query db-coll#) ~@body)]
(exec query#)))
(defmacro partial-query (defmacro partial-query
[& body] [& body]