upgrade to neo4j v4 and inmemory connection

need to rework all queries to $ syntax
neo4j-4
Josha von Gizycki 4 years ago
parent 5165be07ac
commit 337422ae16

@ -7,12 +7,12 @@
:dependencies [;;clojure core
[org.clojure/clojure "1.10.1"]
[nrepl "0.7.0"]
[nrepl "0.8.3"]
;; static site
[compojure "1.6.1"]
[compojure "1.6.2"]
[ring/ring-defaults "0.3.2"]
[ring/ring-jetty-adapter "1.8.0"
[ring/ring-jetty-adapter "1.8.2"
:exclusions [ring/ring-core
ring/ring-codec
commons-io
@ -24,20 +24,18 @@
;; compojure uses old transitive dependencies of ring
;; specifiy them here explicitly so newer versions
;; will be used
[ring/ring-core "1.8.0"]
[ring/ring-core "1.8.2"]
[ring/ring-codec "1.1.2"]
;; neo4j
[gorillalabs/neo4j-clj "2.0.1"
:exclusions [org.bouncycastle/bcprov-jdk15on
org.bouncycastle/bcpkix-jdk15on
com.github.ben-manes.caffeine/caffeine]]
[gorillalabs/neo4j-clj "4.1.0"]
[org.neo4j.test/neo4j-harness "4.0.0"]
;; additional server side libs
[buddy/buddy-hashers "1.4.0"
[buddy/buddy-hashers "1.7.0"
:exclusions [commons-codec]]
[clj-time "0.15.2"]
[markdown-clj "1.10.1"]
[markdown-clj "1.10.5"]
[dorothy "0.0.7"]]
:profiles {:dev {:plugins [;; neo4j db

@ -1,11 +1,13 @@
(ns wanijo.infrastructure.neo4j
(:require [neo4j-clj.core :as db]
[neo4j-clj.in-memory :as db-inm]
[wanijo.infrastructure.devmode :as devmode]
[clj-time.format :as time-format]
[clj-time.local :as time-local]
[clojure.spec.alpha :as spec]
[clojure.string :as cljs])
(:import (java.util UUID)))
(:import (java.util UUID)
(java.net URI)))
(spec/def ::date-str
#(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)))
([port host user pass]
(db/connect
(str "bolt://" host ":" port)
(URI. (str "bolt://" host ":" port))
user
pass)))
@ -42,6 +44,9 @@
([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))
(defn uuid []
@ -57,9 +62,7 @@
(cljs/join \newline)))
(defn exec-query! [qry params]
(let [live-conn (if (nil? @conn)
(reset-conn!)
@conn)]
(let [live-conn (or @conn (reset-conn!))]
(with-open [session (db/get-session live-conn)]
(devmode/send-to-bar
(str (butiful-query qry)

@ -5,9 +5,9 @@
(neo4j/defquery create-user
"CREATE (n:user)
SET n.ident = {ident}
SET n.pw = {pw}
SET n.uuid = {uuid}")
SET n.ident = $ident
SET n.pw = $pw
SET n.uuid = $uuid")
(defn create-user! [ident pw]
(neo4j/exec-query!
@ -114,8 +114,13 @@
(main/start-server-dev!)
(println "Started server at http://localhost:8080"))
(defn setup-in-memory! []
(neo4j/in-memory-conn!)
(create-user! "admin" "admin"))
(comment
(dev-server!)
(setup-in-memory!)
(neo4j/reset-conn! "7688"
"mokoscha"
neo4j/standard-user

@ -140,10 +140,10 @@
(let [names (-> req :params :name)
instances (-> req :params :instances)
source-uuid (-> req :params :source-uuid)]
(clojure.pprint/pprint names)
(clojure.pprint/pprint instances)
(clojure.pprint/pprint source-uuid)
(clojure.pprint/pprint
; (clojure.pprint/pprint names)
; (clojure.pprint/pprint instances)
; (clojure.pprint/pprint source-uuid)
#_ (clojure.pprint/pprint
(map (fn [[target-schema target-instances]]
{:link-name (get names target-schema)
:instances target-instances})

@ -1,6 +1,7 @@
(ns wanijo.user.db
(:require [clojure.spec.alpha :as spec]
[wanijo.infrastructure.neo4j :as neo4j]))
[wanijo.infrastructure.neo4j :as neo4j]
[neo4j-clj.core :as db]))
(spec/def ::ident
(spec/and string? not-empty))
@ -24,6 +25,20 @@
first
:n))
(comment
(macroexpand '(db/defquery test-find-user
"MATCH (u:user) WHERE u.ident = {ident} RETURN u"))
(macroexpand '(neo4j/defquery
find-user
"MATCH (n:user) WHERE n.ident = {ident} RETURN n"))
(require '[neo4j-clj.core :as db])
(db/defquery test-find-user
"MATCH (u:user) WHERE u.ident = {ident} RETURN u")
(with-open [s (db/get-session @neo4j/conn)]
(test-find-user s {:ident "admin"}))
(neo4j/exec-query! test-find-user {:ident "admin"}))
(neo4j/defquery
all
"MATCH (u:user)

Loading…
Cancel
Save