Add $eq operator

This commit is contained in:
Juha Jokimaki 2016-10-30 17:50:07 +02:00
parent 2021c6d07f
commit 82c76dd66d
2 changed files with 18 additions and 0 deletions

View file

@ -80,6 +80,12 @@
;; (mgcol/find-maps "languages" { :tags { $nin [ "functional" ] } } )
(defoperator $nin)
;; $eq is "equals" comparator
;;
;; EXAMPLES:
;; (monger.collection/find "libraries" { :language { $eq "Clojure" }})
(defoperator $eq)
;; $ne is "non-equals" comparator
;;
;; EXAMPLES:

View file

@ -54,6 +54,18 @@
2 {:users {$lte 5}}
1 {:users {$gt 10 $lt 150}})))
;;
;; $eq
;;
(deftest find-with-eq-operator
(let [collection "libraries"]
(mc/insert-batch db collection [{:language "Ruby" :name "mongoid" :users 1 :displayName nil}
{:language "Clojure" :name "langohr" :users 5}
{:language "Clojure" :name "incanter" :users 15}
{:language "Scala" :name "akka" :users 150}])
(is (= 2 (.count (mc/find db collection {:language {$eq "Clojure"}}))))))
;;
;; $ne
;;