monger.gridfs/find-one-as-map is next to useless, remove it

It does not allow you access file content stream.
This commit is contained in:
Michael S. Klishin 2011-12-31 16:27:56 +04:00
parent a292f082e8
commit cb9ed8edb5
2 changed files with 3 additions and 10 deletions

View file

@ -71,27 +71,20 @@
(defprotocol Finders (defprotocol Finders
(find-one [input] "Finds one file using given input (an ObjectId, filename or query)") (find-one [input] "Finds one file using given input (an ObjectId, filename or query)"))
(find-one-as-map [input] "Finds one file using given input (an ObjectId, filename or query), converting result to Clojure map before returning"))
(extend-protocol Finders (extend-protocol Finders
String String
(find-one [^String input] (find-one [^String input]
(.findOne ^GridFS monger.core/*mongodb-gridfs* input)) (.findOne ^GridFS monger.core/*mongodb-gridfs* input))
(find-one-as-map [^String input]
(from-db-object (find-one input) true))
org.bson.types.ObjectId org.bson.types.ObjectId
(find-one [^org.bson.types.ObjectId input] (find-one [^org.bson.types.ObjectId input]
(.findOne ^GridFS monger.core/*mongodb-gridfs* input)) (.findOne ^GridFS monger.core/*mongodb-gridfs* input))
(find-one-as-map [^org.bson.types.ObjectId input]
(from-db-object (find-one input) true))
DBObject DBObject
(find-one [^DBObject input] (find-one [^DBObject input]
(.findOne ^GridFS monger.core/*mongodb-gridfs* input)) (.findOne ^GridFS monger.core/*mongodb-gridfs* input)))
(find-one-as-map [^DBObject input]
(from-db-object (find-one input) true)))

View file

@ -74,7 +74,7 @@
(is (= md5 (:md5 stored))) (is (= md5 (:md5 stored)))
(is (= filename (:filename stored))) (is (= filename (:filename stored)))
(is (= ct (:contentType stored))) (is (= ct (:contentType stored)))
(are [a b] (is (= a (:md5 (gridfs/find-one-as-map b)))) (are [a b] (is (= a (:md5 (from-db-object (gridfs/find-one b) true))))
md5 (:_id stored) md5 (:_id stored)
md5 filename md5 filename
md5 (to-db-object { :md5 md5 })))) md5 (to-db-object { :md5 md5 }))))