Require options in monger.collection to be maps (pseudo-kwargs are no longer supported)

This commit is contained in:
Michael Klishin 2014-05-10 17:55:28 -04:00
parent 58d426d6aa
commit a3954f3847

View file

@ -212,22 +212,22 @@
(mgcol/find-and-modify db collection {:language \"Python\"} {:language \"Clojure\"}) (mgcol/find-and-modify db collection {:language \"Python\"} {:language \"Clojure\"})
;; If multiple documents match, choose the first one in the specified order ;; If multiple documents match, choose the first one in the specified order
(mgcol/find-and-modify db collection {:language \"Python\"} {:language \"Clojure\"} :sort {:language -1}) (mgcol/find-and-modify db collection {:language \"Python\"} {:language \"Clojure\"} {:sort {:language -1}})
;; Remove the object before returning ;; Remove the object before returning
(mgcol/find-and-modify db collection {:language \"Python\"} {} :remove true) (mgcol/find-and-modify db collection {:language \"Python\"} {} {:remove true})
;; Return the modified object instead of the old one ;; Return the modified object instead of the old one
(mgcol/find-and-modify db collection {:language \"Python\"} {:language \"Clojure\"} :return-new true) (mgcol/find-and-modify db collection {:language \"Python\"} {:language \"Clojure\"} {:return-new true})
;; Retrieve a subset of fields ;; Retrieve a subset of fields
(mgcol/find-and-modify db collection {:language \"Python\"} {:language \"Clojure\"} :fields [ :language ]) (mgcol/find-and-modify db collection {:language \"Python\"} {:language \"Clojure\"} {:fields [ :language ]})
;; Create the object if it doesn't exist ;; Create the object if it doesn't exist
(mgcol/find-and-modify db collection {:language \"Factor\"} {:language \"Clojure\"} :upsert true) (mgcol/find-and-modify db collection {:language \"Factor\"} {:language \"Clojure\"} {:upsert true})
" "
([^DB db ^String coll ^Map conditions ^Map document & {:keys [fields sort remove return-new upsert keywordize] :or ([^DB db ^String coll ^Map conditions ^Map document {:keys [fields sort remove return-new upsert keywordize] :or
{fields nil {fields nil
sort nil sort nil
remove false remove false
@ -349,10 +349,10 @@
(monger.collection/update db \"people\" {} {\"$set\" {:band \"The Beatles\"}} :multi true) (monger.collection/update db \"people\" {} {\"$set\" {:band \"The Beatles\"}} :multi true)
;; inserts the record if it did not exist in the collection ;; inserts the record if it did not exist in the collection
(monger.collection/update db \"people\" {:first_name \"Yoko\"} {:first_name \"Yoko\" :last_name \"Ono\"} :upsert true) (monger.collection/update db \"people\" {:first_name \"Yoko\"} {:first_name \"Yoko\" :last_name \"Ono\"} {:upsert true)
By default :upsert and :multi are false." By default :upsert and :multi are false."
[^DB db ^String coll ^Map conditions ^Map document & {:keys [upsert multi write-concern] [^DB db ^String coll ^Map conditions ^Map document {:keys [upsert multi write-concern]
:or {upsert false :or {upsert false
multi false multi false
write-concern monger.core/*mongodb-write-concern*}}] write-concern monger.core/*mongodb-write-concern*}}]
@ -370,14 +370,14 @@
sets :upsert to true. sets :upsert to true.
See monger.collection/update documentation" See monger.collection/update documentation"
[^DB db ^String coll ^Map conditions ^Map document & {:keys [multi write-concern] [^DB db ^String coll ^Map conditions ^Map document {:keys [multi write-concern]
:or {multi false :or {multi false
write-concern monger.core/*mongodb-write-concern*}}] write-concern monger.core/*mongodb-write-concern*}}]
(update db coll conditions document :multi multi :write-concern write-concern :upsert true)) (update db coll conditions document {:multi multi :write-concern write-concern :upsert true}))
(defn ^WriteResult update-by-id (defn ^WriteResult update-by-id
"Update a document with given id" "Update a document with given id"
[^DB db ^String coll id ^Map document & {:keys [upsert write-concern] [^DB db ^String coll id ^Map document {:keys [upsert write-concern]
:or {upsert false :or {upsert false
write-concern monger.core/*mongodb-write-concern*}}] write-concern monger.core/*mongodb-write-concern*}}]
(check-not-nil! id "id must not be nil") (check-not-nil! id "id must not be nil")