1.2.3-SNAPSHOT Arrow_down_16x16

fetch-dataset

incanter.mongodb

  • (fetch-dataset & args)
Queries a MongoDB database, accepting the same arguments as
somnium.congomongo/fetch, but returning an Incanter dataset instead
of a sequence of maps.

Examples:

(use '(incanter core datasets mongodb))
(use 'somnium.congomongo)

;; first load some sample data
(def data (get-dataset :airline-passengers))
(view data)

;; a MongoDB server must be running on the localhost on the default port
;; for the following steps.

(mongo! :db "mydb")
(mass-insert! :airline-data (:rows data))

;; and then retrieve it
;; notice that the retrieved data set has two additional columns, :_id :_ns
(view (fetch-dataset :airline-data))

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/mongodb.clj:72 top

(defn fetch-dataset
  "Queries a MongoDB database, accepting the same arguments as 
somnium.congomongo/fetch, but returning an Incanter dataset instead 
of a sequence of maps.

Examples:

   (use '(incanter core datasets mongodb))
   (use 'somnium.congomongo)

   ;; first load some sample data
   (def data (get-dataset :airline-passengers))
   (view data)

   ;; a MongoDB server must be running on the localhost on the default port
   ;; for the following steps.

   (mongo! :db \"mydb\")
   (mass-insert! :airline-data (:rows data))

   ;; and then retrieve it
   ;; notice that the retrieved data set has two additional columns,  :_id :_ns
   (view (fetch-dataset :airline-data))

"
  [& args]
    (let [results (apply fetch args)
	   colnames  (keys (first results))]
      (dataset colnames results)))
Vars in incanter.mongodb/fetch-dataset: defn let
Used in 0 other vars

Comments top

No comments for fetch-dataset. Log in to add a comment.