Add $where operator
This commit is contained in:
parent
08ce1e41b3
commit
8fd4946959
2 changed files with 14 additions and 1 deletions
|
|
@ -96,6 +96,13 @@
|
||||||
(defoperator $regex)
|
(defoperator $regex)
|
||||||
(defoperator $options)
|
(defoperator $options)
|
||||||
|
|
||||||
|
;; Matches documents that satisfy a JavaScript expression.
|
||||||
|
;;
|
||||||
|
;; EXAMPLES:
|
||||||
|
;;
|
||||||
|
;; (monger.collection/find "people" { $where "this.placeOfBirth === this.address.city" })
|
||||||
|
(defoperator $where)
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;; LOGIC OPERATORS
|
;; LOGIC OPERATORS
|
||||||
;;
|
;;
|
||||||
|
|
|
||||||
|
|
@ -125,4 +125,10 @@
|
||||||
{:language {$regex "clo.*" $options "i"}} 2
|
{:language {$regex "clo.*" $options "i"}} 2
|
||||||
{:name {$regex "aK.*" $options "i"}} 1
|
{:name {$regex "aK.*" $options "i"}} 1
|
||||||
{:language {$regex ".*by"}} 1
|
{:language {$regex ".*by"}} 1
|
||||||
{:language {$regex ".*ala.*"}} 1))))
|
{:language {$regex ".*ala.*"}} 1)))
|
||||||
|
|
||||||
|
(deftest find-with-js-expression
|
||||||
|
(let [collection "people"]
|
||||||
|
(mc/insert-batch db collection [{:name "Bob" :placeOfBirth "New York" :address {:city "New York"}}
|
||||||
|
{:name "Alice" :placeOfBirth "New York" :address {:city "Los Angeles"}}])
|
||||||
|
(is (= 1 (.count (mc/find db collection {$where "this.placeOfBirth === this.address.city"})))))))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue