From 5bbac64801be8e8146d1a730dca5d7a76ceceb4e Mon Sep 17 00:00:00 2001 From: "Michael S. Klishin" Date: Sat, 31 Dec 2011 03:23:52 +0400 Subject: [PATCH] Query DSL composition example --- test/monger/test/querying.clj | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/test/monger/test/querying.clj b/test/monger/test/querying.clj index 1e12522..44d5caa 100644 --- a/test/monger/test/querying.clj +++ b/test/monger/test/querying.clj @@ -106,8 +106,22 @@ (find { :inception_year { "$gt" 2002 } }) (limit 1) (sort { :inception_year -1 }))) - (doc1 (with-collection coll - (find { :inception_year { "$gte" 2006 } })))))) + (doc1 (with-collection coll + (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