Adding some docs for operators.
This commit is contained in:
parent
01063a3476
commit
1124316793
1 changed files with 28 additions and 2 deletions
|
|
@ -43,12 +43,40 @@
|
||||||
;; (monger.collection/find "libraries" {$ne { :language "Clojure" }})
|
;; (monger.collection/find "libraries" {$ne { :language "Clojure" }})
|
||||||
(defoperator $ne)
|
(defoperator $ne)
|
||||||
|
|
||||||
|
;; $elemMatch checks if an element in an array matches the specified expression
|
||||||
|
;;
|
||||||
|
;; EXAMPLES:
|
||||||
|
;; ;; Matches element with :text "Nice" and :rating greater than or equal 1
|
||||||
|
;; (monger.collection/find "comments" { $elemMatch { :text "Nice!" :rating { $gte 1 } } })
|
||||||
|
(defoperator $elemMatch)
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;; LOGIC OPERATORS
|
;; LOGIC OPERATORS
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
;; $and lets you use a boolean and in the query. Logical and means that all the given expressions should be true for positive match.
|
||||||
|
;;
|
||||||
|
;; EXAMPLES:
|
||||||
|
;;
|
||||||
|
;; ;; Matches all libraries where :language is "Clojure" and :users is greater than 10
|
||||||
|
;; (monger.collection/find "libraries" { $and [{ :language "Clojure" } { :users { $gt 10 } }] })
|
||||||
(defoperator $and)
|
(defoperator $and)
|
||||||
|
|
||||||
|
;; $or lets you use a boolean or in the query. Logical or means that one of the given expressions should be true for positive match.
|
||||||
|
;;
|
||||||
|
;; EXAMPLES:
|
||||||
|
;;
|
||||||
|
;; ;; Matches all libraries whose :name is "mongoid" or :language is "Ruby"
|
||||||
|
;; (monger.collection.find "libraries" { $or [ { :name "mongoid" } { :language "Ruby" } ] })
|
||||||
(defoperator $or)
|
(defoperator $or)
|
||||||
|
|
||||||
|
;; @nor lets you use a boolean expression, opposite to "all" in the query (think: neither). Give $nor a list of expressions, all of which should
|
||||||
|
;; be false for positive match.
|
||||||
|
;;
|
||||||
|
;; EXAMPLES:
|
||||||
|
;;
|
||||||
|
;; (monger.collection/find "libraries" { $nor [{ :language "Clojure" } {:users { $gt 10 } } ]})
|
||||||
(defoperator $nor)
|
(defoperator $nor)
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
@ -126,6 +154,4 @@
|
||||||
;; (mgcol/update coll { :_id oid } { $pull { :measurements { $gte 1.2 } } })
|
;; (mgcol/update coll { :_id oid } { $pull { :measurements { $gte 1.2 } } })
|
||||||
(defoperator $pullAll)
|
(defoperator $pullAll)
|
||||||
|
|
||||||
(defoperator $elemMatch)
|
|
||||||
|
|
||||||
(defoperator $bit)
|
(defoperator $bit)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue