|
|
@ -1,11 +1,13 @@
|
|
|
|
(ns wanijo.infrastructure.neo4j
|
|
|
|
(ns wanijo.infrastructure.neo4j
|
|
|
|
(:require [neo4j-clj.core :as db]
|
|
|
|
(:require [neo4j-clj.core :as db]
|
|
|
|
|
|
|
|
[neo4j-clj.in-memory :as db-inm]
|
|
|
|
[wanijo.infrastructure.devmode :as devmode]
|
|
|
|
[wanijo.infrastructure.devmode :as devmode]
|
|
|
|
[clj-time.format :as time-format]
|
|
|
|
[clj-time.format :as time-format]
|
|
|
|
[clj-time.local :as time-local]
|
|
|
|
[clj-time.local :as time-local]
|
|
|
|
[clojure.spec.alpha :as spec]
|
|
|
|
[clojure.spec.alpha :as spec]
|
|
|
|
[clojure.string :as cljs])
|
|
|
|
[clojure.string :as cljs])
|
|
|
|
(:import (java.util UUID)))
|
|
|
|
(:import (java.util UUID)
|
|
|
|
|
|
|
|
(java.net URI)))
|
|
|
|
|
|
|
|
|
|
|
|
(spec/def ::date-str
|
|
|
|
(spec/def ::date-str
|
|
|
|
#(re-matches #"\d{4}\d{2}\d{2}T\d{2}\d{2}\d{2}\.\d{3}Z" %))
|
|
|
|
#(re-matches #"\d{4}\d{2}\d{2}T\d{2}\d{2}\d{2}\.\d{3}Z" %))
|
|
|
@ -29,7 +31,7 @@
|
|
|
|
(create-conn! port host user pass)))
|
|
|
|
(create-conn! port host user pass)))
|
|
|
|
([port host user pass]
|
|
|
|
([port host user pass]
|
|
|
|
(db/connect
|
|
|
|
(db/connect
|
|
|
|
(str "bolt://" host ":" port)
|
|
|
|
(URI. (str "bolt://" host ":" port))
|
|
|
|
user
|
|
|
|
user
|
|
|
|
pass)))
|
|
|
|
pass)))
|
|
|
|
|
|
|
|
|
|
|
@ -42,6 +44,9 @@
|
|
|
|
([port host user pass]
|
|
|
|
([port host user pass]
|
|
|
|
(reset! conn (create-conn! port host user pass))))
|
|
|
|
(reset! conn (create-conn! port host user pass))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defn in-memory-conn! []
|
|
|
|
|
|
|
|
(reset! conn (db-inm/create-in-memory-connection)))
|
|
|
|
|
|
|
|
|
|
|
|
(defmacro defquery [& args] `(db/defquery ~@args))
|
|
|
|
(defmacro defquery [& args] `(db/defquery ~@args))
|
|
|
|
|
|
|
|
|
|
|
|
(defn uuid []
|
|
|
|
(defn uuid []
|
|
|
@ -57,9 +62,7 @@
|
|
|
|
(cljs/join \newline)))
|
|
|
|
(cljs/join \newline)))
|
|
|
|
|
|
|
|
|
|
|
|
(defn exec-query! [qry params]
|
|
|
|
(defn exec-query! [qry params]
|
|
|
|
(let [live-conn (if (nil? @conn)
|
|
|
|
(let [live-conn (or @conn (reset-conn!))]
|
|
|
|
(reset-conn!)
|
|
|
|
|
|
|
|
@conn)]
|
|
|
|
|
|
|
|
(with-open [session (db/get-session live-conn)]
|
|
|
|
(with-open [session (db/get-session live-conn)]
|
|
|
|
(devmode/send-to-bar
|
|
|
|
(devmode/send-to-bar
|
|
|
|
(str (butiful-query qry)
|
|
|
|
(str (butiful-query qry)
|
|
|
|