Don't assume ids are ObjectId instances (for caches it may be different)

This commit is contained in:
Michael S. Klishin 2012-04-11 20:56:47 +04:00
parent 7ef48e9bb4
commit 30a4ae4ea0

View file

@ -312,7 +312,7 @@
(defn ^WriteResult update-by-id (defn ^WriteResult update-by-id
"Update a document with given id" "Update a document with given id"
[^String collection ^ObjectId id ^Map document & { :keys [upsert write-concern] :or { upsert false [^String collection id ^Map document & { :keys [upsert write-concern] :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")
(let [^DBCollection coll (.getCollection monger.core/*mongodb-database* collection)] (let [^DBCollection coll (.getCollection monger.core/*mongodb-database* collection)]
@ -367,9 +367,9 @@
(defn ^WriteResult remove-by-id (defn ^WriteResult remove-by-id
"Removes a single document with given id" "Removes a single document with given id"
([^String collection ^ObjectId id] ([^String collection id]
(remove-by-id monger.core/*mongodb-database* collection id)) (remove-by-id monger.core/*mongodb-database* collection id))
([^DB db ^String collection ^ObjectId id] ([^DB db ^String collection id]
(check-not-nil! id "id must not be nil") (check-not-nil! id "id must not be nil")
(let [^DBCollection coll (.getCollection db collection)] (let [^DBCollection coll (.getCollection db collection)]
(.remove coll (to-db-object { :_id id }))))) (.remove coll (to-db-object { :_id id })))))