Merge f133fbe256 into b72968dfb9
This commit is contained in:
commit
bbda2189a6
2 changed files with 16 additions and 12 deletions
|
|
@ -7,7 +7,8 @@
|
||||||
[org.mongodb/mongo-java-driver "2.11.2"]
|
[org.mongodb/mongo-java-driver "2.11.2"]
|
||||||
[com.novemberain/validateur "1.5.0"]
|
[com.novemberain/validateur "1.5.0"]
|
||||||
[clojurewerkz/support "0.19.0"]
|
[clojurewerkz/support "0.19.0"]
|
||||||
[ragtime/ragtime.core "0.3.4"]]
|
[ragtime/ragtime.core "0.3.4"]
|
||||||
|
[clj-yield "1.1"]]
|
||||||
:test-selectors {:default (fn [m]
|
:test-selectors {:default (fn [m]
|
||||||
(and (not (:performance m))
|
(and (not (:performance m))
|
||||||
(not (:edge-features m))
|
(not (:edge-features m))
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,8 @@
|
||||||
[monger.cursor :as cursor :refer [add-options]])
|
[monger.cursor :as cursor :refer [add-options]])
|
||||||
(:import [com.mongodb DB DBCollection DBObject DBCursor ReadPreference]
|
(:import [com.mongodb DB DBCollection DBObject DBCursor ReadPreference]
|
||||||
[java.util List])
|
[java.util List])
|
||||||
(:use [monger conversion operators]))
|
(:use [monger conversion operators]
|
||||||
|
[yield]))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
@ -65,21 +66,23 @@
|
||||||
|
|
||||||
(defn exec
|
(defn exec
|
||||||
[{ :keys [^DBCollection collection query fields skip limit sort batch-size hint snapshot read-preference keywordize-fields options] :or { limit 0 batch-size 256 skip 0 } }]
|
[{ :keys [^DBCollection collection query fields skip limit sort batch-size hint snapshot read-preference keywordize-fields options] :or { limit 0 batch-size 256 skip 0 } }]
|
||||||
(with-open [cursor (doto (.find collection (to-db-object query) (as-field-selector fields))
|
(with-yielding [y-out 1]
|
||||||
|
(with-open [cursor (doto (.find collection (to-db-object query) (as-field-selector fields))
|
||||||
(.limit limit)
|
(.limit limit)
|
||||||
(.skip skip)
|
(.skip skip)
|
||||||
(.sort (to-db-object sort))
|
(.sort (to-db-object sort))
|
||||||
(.batchSize batch-size)
|
(.batchSize batch-size)
|
||||||
(.hint (to-db-object hint)))]
|
(.hint (to-db-object hint)))]
|
||||||
(when snapshot
|
(when snapshot
|
||||||
(.snapshot cursor))
|
(.snapshot cursor))
|
||||||
(when read-preference
|
(when read-preference
|
||||||
(.setReadPreference cursor read-preference))
|
(.setReadPreference cursor read-preference))
|
||||||
(when options
|
(when options
|
||||||
(add-options cursor options))
|
(add-options cursor options))
|
||||||
(map (fn [x] (from-db-object x keywordize-fields))
|
(loop []
|
||||||
cursor)))
|
(when (.hasNext cursor)
|
||||||
|
(yield y-out (from-db-object (.next cursor) keywordize-fields))
|
||||||
|
(recur))))))
|
||||||
;;
|
;;
|
||||||
;; API
|
;; API
|
||||||
;;
|
;;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue