连接,我开始使用Clojure的Luminus公司框架与MongoDB的(与商贩库)来开发。 很难理解如何实现mount
库来启动数据库连接。Clojure的Luminus公司架构如何调用MongoDB的与安装
我想出代码应该放handler.clj
的init
函数。
但我不知道如何告诉安装启动数据库连接。
请你能帮我一下吗?
这里爱顶我的发展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 successfully using the development profile]=-"))
:middleware wrap-dev})
和handler.clj
的init
功能
(defn init
"init will be called once when
app is deployed as a servlet on
an app server such as Tomcat
put any 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)))
我的主要问题是我应该如何调用该函数从init
有道
(defn connect! []
;; Tries to get the Mongo URI from the environment variable
(reset! db (-> (:database-url env) mg/connect-via-uri :db)))
请再具体些,如果你提供你试图实现,我们也许能够告诉你哪里出了问题。 –
@RicardoAcuna谢谢。我添加了代码,我认为是相关的 – shan