parent
4e5c86b808
commit
21ef517cec
@ -0,0 +1,33 @@
|
||||
(ns wanijo.instance.revision.db
|
||||
(:require [wanijo.infra.neo4j :as neo4j]))
|
||||
|
||||
(neo4j/defquery save-revision
|
||||
"MATCH (i:instance)
|
||||
WHERE i.uuid = $uuid
|
||||
CREATE (r:revision)-[:of]->(i)
|
||||
SET r.uuid = $rev_uuid,
|
||||
r.instance_name = $name,
|
||||
r.created_at = $now")
|
||||
(neo4j/defquery save-revision-property
|
||||
"MATCH (r:revision)
|
||||
WHERE r.uuid = $rev_uuid
|
||||
CREATE (rp:rev_property)-[:of]->(r)
|
||||
SET rp.uuid = $rp_uuid,
|
||||
rp.value = $value,
|
||||
rp.type = $type,
|
||||
rp.created_at = $now")
|
||||
(defn revision-queries [revision]
|
||||
(let [rev-uuid (neo4j/uuid)]
|
||||
(concat [[save-revision
|
||||
{:uuid (:instance-uuid revision)
|
||||
:rev_uuid rev-uuid
|
||||
:name (:instance-name revision)
|
||||
:now (neo4j/now-str)}]]
|
||||
(map (fn [{:keys [value type]}]
|
||||
[save-revision-property
|
||||
{:rev_uuid rev-uuid
|
||||
:rp_uuid (neo4j/uuid)
|
||||
:value value
|
||||
:type type
|
||||
:now (neo4j/now-str)}])
|
||||
(:properties revision)))))
|
Loading…
Reference in new issue