Clojure luminus framework how to call mongodb connect with mount -
i started develop using clojure luminus framework mongodb (with monger library). hard understand how implement mount library start db connection.
i figured out code should put handler.clj 's init function.
but cannot figure out how tell mount start database connection.
please give me hand?
here gores development config.clj
(ns vippro.config (:require [selmer.parser :as parser] [clojure.tools.logging :as log] [vippro.dev-middleware :refer [wrap-dev]] )) (def defaults {:init (fn [] (parser/cache-off!) (log/info "\n-=[vippro started using development profile]=-")) :middleware wrap-dev}) and in handler.clj 's init function
(defn init "init called once when app deployed servlet on app server such tomcat put initialization code here" [] (when-let [config (:log-config env)] (org.apache.log4j.propertyconfigurator/configure config)) (doseq [component (:started (mount/start))] (log/info component "started")) ((:init defaults))) my main problem how should call function init proper way
(defn connect! [] ;; tries mongo uri environment variable (reset! db (-> (:database-url env) mg/connect-via-uri :db)))
the mongodb database started automatically when set environment variable
export database_url="mongodb://127.0.0.1/dbname" and started ring server
Comments
Post a Comment