Merge pull request #47 from zussitarze/master
Close DBCurors in find-maps
This commit is contained in:
commit
8fd78c3a19
2 changed files with 22 additions and 14 deletions
|
|
@ -164,24 +164,32 @@
|
||||||
If you want to work directly with DBObject, use find.
|
If you want to work directly with DBObject, use find.
|
||||||
"
|
"
|
||||||
([^String collection]
|
([^String collection]
|
||||||
(map (fn [x] (from-db-object x true)) (find collection)))
|
(with-open [dbc (find collection)]
|
||||||
|
(map (fn [x] (from-db-object x true)) dbc)))
|
||||||
([^String collection ^Map ref]
|
([^String collection ^Map ref]
|
||||||
(map (fn [x] (from-db-object x true)) (find collection ref)))
|
(with-open [dbc (find collection ref)]
|
||||||
|
(map (fn [x] (from-db-object x true)) dbc)))
|
||||||
([^String collection ^Map ref fields]
|
([^String collection ^Map ref fields]
|
||||||
(map (fn [x] (from-db-object x true)) (find collection ref fields)))
|
(with-open [dbc (find collection ref fields)]
|
||||||
|
(map (fn [x] (from-db-object x true)) dbc)))
|
||||||
([^DB db ^String collection ^Map ref fields]
|
([^DB db ^String collection ^Map ref fields]
|
||||||
(map (fn [x] (from-db-object x true)) (find db collection ref fields))))
|
(with-open [dbc (find db collection ref fields)]
|
||||||
|
(map (fn [x] (from-db-object x true)) dbc))))
|
||||||
|
|
||||||
(defn find-seq
|
(defn find-seq
|
||||||
"Queries for objects in this collection, returns ISeq of DBObjects."
|
"Queries for objects in this collection, returns ISeq of DBObjects."
|
||||||
([^String collection]
|
([^String collection]
|
||||||
(seq (find collection)))
|
(with-open [dbc (find collection)]
|
||||||
|
(seq dbc)))
|
||||||
([^String collection ^Map ref]
|
([^String collection ^Map ref]
|
||||||
(seq (find collection ref)))
|
(with-open [dbc (find collection ref)]
|
||||||
|
(seq dbc)))
|
||||||
([^String collection ^Map ref fields]
|
([^String collection ^Map ref fields]
|
||||||
(seq (find collection ref fields)))
|
(with-open [dbc (find collection ref fields)]
|
||||||
|
(seq dbc)))
|
||||||
([^DB db ^String collection ^Map ref fields]
|
([^DB db ^String collection ^Map ref fields]
|
||||||
(seq (find db collection ref fields))))
|
(with-open [dbc (find db collection ref fields)]
|
||||||
|
(seq dbc))))
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;; monger.collection/find-one
|
;; monger.collection/find-one
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@
|
||||||
|
|
||||||
(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 } }]
|
||||||
(let [cursor (doto (.find collection (to-db-object query) (as-field-selector fields))
|
(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))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue