|
|
|
@ -1,11 +1,9 @@
|
|
|
|
|
(ns wanijo.domain.schema
|
|
|
|
|
(:require [clojurewerkz.neocons.rest.cypher :as cypher]
|
|
|
|
|
[clojure.spec.alpha :as spec]
|
|
|
|
|
[wanijo.neo4j :as neo4j]
|
|
|
|
|
[wanijo.devmode :as devmode]))
|
|
|
|
|
(:require [clojure.spec.alpha :as spec]
|
|
|
|
|
[wanijo.neo4j :as neo4j]))
|
|
|
|
|
|
|
|
|
|
(spec/def ::name
|
|
|
|
|
(spec/and string? not-empty int?))
|
|
|
|
|
(spec/and string? not-empty))
|
|
|
|
|
|
|
|
|
|
(spec/def ::created-at
|
|
|
|
|
(spec/or :int (spec/and int?
|
|
|
|
@ -13,13 +11,27 @@
|
|
|
|
|
:str (spec/and string?
|
|
|
|
|
#(re-matches #"\d{4}\d{2}\d{2}\d{2}\d{2}\d{2}" %))))
|
|
|
|
|
|
|
|
|
|
(defn all-created-by! [ident]
|
|
|
|
|
(defn all-created-by! [user-uuid]
|
|
|
|
|
(neo4j/query-rawdata!
|
|
|
|
|
:query
|
|
|
|
|
"MATCH (s:schema)-[:created_by]->(u:user)
|
|
|
|
|
WHERE u.ident = {ident}
|
|
|
|
|
WHERE u.uuid = {uuid}
|
|
|
|
|
RETURN s
|
|
|
|
|
ORDER BY s.name"
|
|
|
|
|
:params {:ident ident}
|
|
|
|
|
:alias "s"
|
|
|
|
|
))
|
|
|
|
|
:params {:uuid user-uuid}
|
|
|
|
|
:alias "s"))
|
|
|
|
|
|
|
|
|
|
(defn create-new! [name user-uid]
|
|
|
|
|
(:uuid
|
|
|
|
|
(neo4j/query-rawdata!
|
|
|
|
|
:query
|
|
|
|
|
"MATCH (u:user)
|
|
|
|
|
WHERE u.uuid = {u_uuid}
|
|
|
|
|
CREATE (s:schema)-[:created_by]->(u)
|
|
|
|
|
SET s.name = {name}
|
|
|
|
|
SET s.uuid = {s_uuid}
|
|
|
|
|
RETURN s"
|
|
|
|
|
:params {:u_uuid user-uid
|
|
|
|
|
:name name
|
|
|
|
|
:s_uuid (neo4j/uuid)}
|
|
|
|
|
:alias "s")))
|
|
|
|
|