Skip to content

Instantly share code, notes, and snippets.

@swaroopch
Created September 26, 2012 11:23
Show Gist options
  • Save swaroopch/3787439 to your computer and use it in GitHub Desktop.
Save swaroopch/3787439 to your computer and use it in GitHub Desktop.
Figuring out how to use Monger (Clojure MongoDB library) with multiple databases
(ns scratchpad.core
(:require [monger.core :as mg]
[monger.collection :as mc]
[monger.query :as mq]))
(def local-mongodb
(.getDB (mg/connect-via-uri! "mongodb://127.0.0.1:27017/local") "local"))
(def remote-mongodb
(.getDB (mg/connect-via-uri! (System/getenv "REMOTE_MONGODB_URL")) "app9876543"))
(def collection-names
["A"
"B"
"C"
"D"])
(defn -main
[& args]
(doseq [collection-name collection-names]
(println collection-name)
(println (mc/count local-mongodb collection-name {}))
(println (mc/count remote-mongodb collection-name {}))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment