1.2.3-SNAPSHOT Arrow_down_16x16

$where

incanter.core

  • ($where query-map)
  • ($where query-map data)
An alias to (query-dataset (second args) (first args)). If given only a single argument,
it will use the $data binding for the first argument, which is set with
the with-data macro.

Examples:

(use '(incanter core datasets))

(def cars (get-dataset :cars))
($where {:speed 10} cars)

;; use the with-data macro and the one arg version of $where
(with-data cars
(view ($where {:speed {:$gt -10 :$lt 10}}))
(view ($where {:dist {:$in #{10 12 16}}}))
(view ($where {:dist {:$nin #{10 12 16}}})))

;; create a dataset where :speed greater than 10 or less than -10
(with-data (get-dataset :cars)
(view (-> ($where {:speed {:$gt 20}})
(conj-rows ($where {:speed {:$lt 10}})))))


0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source incanter/core.clj:1601 top

(defn $where 
"An alias to (query-dataset (second args) (first args)). If given only a single argument,
  it will use the $data binding for the first argument, which is set with
  the with-data macro.

  Examples:

    (use '(incanter core datasets))

    (def cars (get-dataset :cars))
    ($where {:speed 10} cars)

    ;; use the with-data macro and the one arg version of $where
    (with-data cars
      (view ($where {:speed {:$gt -10 :$lt 10}}))     
      (view ($where {:dist {:$in #{10 12 16}}}))
      (view ($where {:dist {:$nin #{10 12 16}}})))

    ;; create a dataset where :speed greater than 10 or less than -10
    (with-data (get-dataset :cars)
      (view (-> ($where {:speed {:$gt 20}}) 
                      (conj-rows ($where {:speed {:$lt 10}})))))
       

"
  ([query-map] 
    (query-dataset $data  query-map))
  ([query-map data] 
     (query-dataset data query-map)))
Vars in incanter.core/$where: defn
Used in 0 other vars

Comments top

No comments for $where. Log in to add a comment.