Find-maps now supports keywordize option
This commit is contained in:
parent
f1fff71577
commit
ebc01b3f54
2 changed files with 12 additions and 2 deletions
|
|
@ -147,8 +147,10 @@
|
|||
(with-open [dbc (find db coll ref)]
|
||||
(map (fn [x] (from-db-object x true)) dbc)))
|
||||
([^DB db ^String coll ^Map ref fields]
|
||||
(find-maps db coll ref fields true))
|
||||
([^DB db ^String coll ^Map ref fields keywordize]
|
||||
(with-open [dbc (find db coll ref fields)]
|
||||
(map (fn [x] (from-db-object x true)) dbc))))
|
||||
(map (fn [x] (from-db-object x keywordize)) dbc))))
|
||||
|
||||
(defn find-seq
|
||||
"Queries for objects in this collection, returns ISeq of DBObjects."
|
||||
|
|
|
|||
|
|
@ -281,4 +281,12 @@
|
|||
(doseq [i clojure-libs]
|
||||
(let [doc (mgcnv/from-db-object i true)]
|
||||
(is (= (:language doc) "Clojure"))))
|
||||
(is (empty? (mc/find db collection { :language "Erlang" } [:name])))))))
|
||||
(is (empty? (mc/find db collection { :language "Erlang" } [:name]))))))
|
||||
|
||||
(deftest find-maps-with-keywordize-false
|
||||
(let [collection "libraries"]
|
||||
(mc/insert-batch db collection [{ :language "Clojure", :name "monger" }
|
||||
{ :language "Clojure", :name "langohr" }])
|
||||
(let [results (mc/find-maps db collection {:name "langohr"} [] false)]
|
||||
(is (= 1 (.count results)))
|
||||
(is (= (get (first results) "language") "Clojure"))))))
|
||||
|
|
|
|||
Loading…
Reference in a new issue