Query DSL composition example

This commit is contained in:
Michael S. Klishin 2011-12-31 03:23:52 +04:00
parent 1cb024dcad
commit 5bbac64801

View file

@ -110,6 +110,20 @@
(find { :inception_year { "$gte" 2006 } })))))) (find { :inception_year { "$gte" 2006 } }))))))
(deftest query-using-$gt-$lt-$gte-$lte-operators-using-dsl-composition
(let [coll "docs"
doc1 { :language "Clojure" :_id (ObjectId.) :inception_year 2006 }
doc2 { :language "Java" :_id (ObjectId.) :inception_year 1992 }
doc3 { :language "Scala" :_id (ObjectId.) :inception_year 2003 }
srt (-> {}
(limit 1)
(sort { :inception_year -1 }))
_ (mgcol/insert-batch coll [doc1 doc2 doc3])]
(is (= [doc1] (with-collection coll
(find { :inception_year { "$gt" 2002 } })
(merge srt))))))
;; $all ;; $all
(deftest query-with-using-$all (deftest query-with-using-$all