Close Cursor in queries
This commit is contained in:
parent
c3d2ed0c74
commit
80219176a4
1 changed files with 6 additions and 6 deletions
|
|
@ -64,12 +64,12 @@
|
|||
|
||||
(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 } }]
|
||||
(let [cursor (doto (.find collection (to-db-object query) (as-field-selector fields))
|
||||
(.limit limit)
|
||||
(.skip skip)
|
||||
(.sort (to-db-object sort))
|
||||
(.batchSize batch-size)
|
||||
(.hint (to-db-object hint)))]
|
||||
(with-open [cursor (doto (.find collection (to-db-object query) (as-field-selector fields))
|
||||
(.limit limit)
|
||||
(.skip skip)
|
||||
(.sort (to-db-object sort))
|
||||
(.batchSize batch-size)
|
||||
(.hint (to-db-object hint)))]
|
||||
(when snapshot
|
||||
(.snapshot cursor))
|
||||
(when read-preference
|
||||
|
|
|
|||
Loading…
Reference in a new issue