add manual changing of neo4j connection

neo4j-4
Josha von Gizycki 4 years ago
parent e72bdf2dff
commit bf890aaed5

@ -14,16 +14,28 @@
#(re-matches
#"[0-9a-f]+-[0-9a-f]+-[0-9a-f]+-[0-9a-f]+-[0-9a-f]+" %))
(defn create-conn!
([]
(let [env #(or (System/getenv %1) %2)
port (env "NEO4J_PORT" "7687")
host (env "NEO4J_HOST" "localhost")
user (env "NEO4J_USER" "neo4j")
pass (env "NEO4J_PASS" "b")]
(create-conn! port host user pass)))
([port host user pass]
(db/connect
(str "bolt://" host ":" port)
user
pass)))
(def conn
(let [env #(or (System/getenv %1) %2)
port (env "NEO4J_PORT" "7687")
host (env "NEO4J_HOST" "localhost")
user (env "NEO4J_USER" "neo4j")
pass (env "NEO4J_PASS" "b")]
(delay (db/connect
(str "bolt://" host ":" port)
user
pass))))
(atom nil))
(defn reset-conn!
([]
(reset! conn (create-conn!)))
([port host user pass]
(reset! conn (create-conn! port host user pass))))
(defmacro defquery [& args] `(db/defquery ~@args))
@ -40,12 +52,15 @@
(cljs/join \newline)))
(defn exec-query! [qry params]
(with-open [session (db/get-session @conn)]
(devmode/send-to-bar
(str (butiful-query qry)
"<br>---Params---<br>"
params))
(qry session params)))
(let [live-conn (if (nil? @conn)
(reset-conn!)
@conn)]
(with-open [session (db/get-session live-conn)]
(devmode/send-to-bar
(str (butiful-query qry)
"<br>---Params---<br>"
params))
(qry session params))))
(spec/def ::tuple-query-list
(spec/coll-of

Loading…
Cancel
Save