Support bitmask DBCursor options, fixes #35
This commit is contained in:
parent
1b6cae729b
commit
9452862f0c
3 changed files with 22 additions and 2 deletions
13
ChangeLog.md
13
ChangeLog.md
|
|
@ -1,5 +1,18 @@
|
|||
## Changes between 1.1.0 and 1.2.0-alpha1
|
||||
|
||||
### Monger Query DSL now supports low level options on cursors
|
||||
|
||||
For example:
|
||||
|
||||
``` clojure
|
||||
(with-collection coll
|
||||
(find {})
|
||||
(paginate :page 1 :per-page 3)
|
||||
(sort { :title 1 })
|
||||
(read-preference ReadPreference/PRIMARY)
|
||||
(options com.mongodb.Bytes/QUERYOPTION_NOTIMEOUT))
|
||||
```
|
||||
|
||||
### monger.collection/insert-and-return no longer forcefully replaces existing document id
|
||||
|
||||
`monger.collection/insert-and-return` now preserves existing document ids, just like `monger.collection/save-and-return` does.
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@
|
|||
(merge (empty-query) { :collection coll })))
|
||||
|
||||
(defn exec
|
||||
[{ :keys [^DBCollection collection query fields skip limit sort batch-size hint snapshot read-preference keywordize-fields] :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))
|
||||
(.limit limit)
|
||||
(.skip skip)
|
||||
|
|
@ -74,6 +74,8 @@
|
|||
(.snapshot cursor))
|
||||
(when read-preference
|
||||
(.setReadPreference cursor read-preference))
|
||||
(when options
|
||||
(.setOptions cursor options))
|
||||
(map (fn [x] (from-db-object x keywordize-fields))
|
||||
cursor)))
|
||||
|
||||
|
|
@ -117,6 +119,10 @@
|
|||
[m ^ReadPreference rp]
|
||||
(merge m { :read-preference rp }))
|
||||
|
||||
(defn options
|
||||
[m opts]
|
||||
(merge m { :options opts }))
|
||||
|
||||
(defn keywordize-fields
|
||||
[m bool]
|
||||
(merge m { :keywordize-fields bool }))
|
||||
|
|
|
|||
|
|
@ -231,7 +231,8 @@
|
|||
(find {})
|
||||
(paginate :page 1 :per-page 3)
|
||||
(sort { :title 1 })
|
||||
(read-preference ReadPreference/PRIMARY))
|
||||
(read-preference ReadPreference/PRIMARY)
|
||||
(options com.mongodb.Bytes/QUERYOPTION_NOTIMEOUT))
|
||||
result2 (with-collection coll
|
||||
(find {})
|
||||
(paginate :page 2 :per-page 3)
|
||||
|
|
|
|||
Loading…
Reference in a new issue