Created
September 26, 2012 11:23
-
-
Save swaroopch/3787439 to your computer and use it in GitHub Desktop.
Figuring out how to use Monger (Clojure MongoDB library) with multiple databases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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