|
|
|
@ -6,7 +6,7 @@
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery findy-by-schema
|
|
|
|
|
"MATCH (i:instance)-[:of]->(s:schema)
|
|
|
|
|
WHERE s.uuid = {uuid}
|
|
|
|
|
WHERE s.uuid = $uuid
|
|
|
|
|
OPTIONAL MATCH
|
|
|
|
|
(i)-[:tagged_with]->(t:tag)
|
|
|
|
|
OPTIONAL MATCH
|
|
|
|
@ -34,21 +34,21 @@
|
|
|
|
|
(sort-by :name)))
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery create-instance
|
|
|
|
|
"MATCH (s:schema {uuid:{schema_uuid}}),
|
|
|
|
|
(u:user {uuid:{user_uuid}})
|
|
|
|
|
CREATE (i:instance {uuid:{uuid}})-[:of]->(s),
|
|
|
|
|
"MATCH (s:schema {uuid: $schema_uuid}),
|
|
|
|
|
(u:user {uuid: $user_uuid})
|
|
|
|
|
CREATE (i:instance {uuid: $uuid})-[:of]->(s),
|
|
|
|
|
(i)-[:created_by]->(u)
|
|
|
|
|
SET i.name = {name},
|
|
|
|
|
i.created_at = {created_at},
|
|
|
|
|
i.updated_at = {created_at}")
|
|
|
|
|
SET i.name = $name,
|
|
|
|
|
i.created_at = $created_at,
|
|
|
|
|
i.updated_at = $created_at")
|
|
|
|
|
(neo4j/defquery create-property
|
|
|
|
|
"MATCH (i:instance {uuid:{uuid}}),
|
|
|
|
|
(a:attribute {uuid:{attr_uuid}})
|
|
|
|
|
CREATE (p:property {uuid:{prop_uuid}})-[:of]->(i),
|
|
|
|
|
"MATCH (i:instance {uuid: $uuid}),
|
|
|
|
|
(a:attribute {uuid: $attr_uuid})
|
|
|
|
|
CREATE (p:property {uuid: $prop_uuid})-[:of]->(i),
|
|
|
|
|
(p)-[:of]->(a)
|
|
|
|
|
SET p.value = {value},
|
|
|
|
|
p.created_at = {created_at},
|
|
|
|
|
p.updated_at = {updated_at}")
|
|
|
|
|
SET p.value = $value,
|
|
|
|
|
p.created_at = $created_at,
|
|
|
|
|
p.updated_at = $updated_at")
|
|
|
|
|
(defn create! [user-uuid
|
|
|
|
|
schema-uuid
|
|
|
|
|
{:keys [name properties]}]
|
|
|
|
@ -73,7 +73,7 @@
|
|
|
|
|
prop-tuples))))
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery find-by-uuid
|
|
|
|
|
"MATCH (i:instance {uuid:{uuid}})-[:of]->(s:schema)
|
|
|
|
|
"MATCH (i:instance {uuid: $uuid})-[:of]->(s:schema)
|
|
|
|
|
RETURN i, s")
|
|
|
|
|
(defn find-by-uuid! [uuid]
|
|
|
|
|
{:post [(spec/assert ::domain-instance/instance-with-schema %)]}
|
|
|
|
@ -85,7 +85,7 @@
|
|
|
|
|
first))
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery find-properties
|
|
|
|
|
"MATCH (i:instance {uuid:{uuid}}),
|
|
|
|
|
"MATCH (i:instance {uuid: $uuid}),
|
|
|
|
|
(p:property)-[:of]->(i),
|
|
|
|
|
(p)-[:of]->(a:attribute)
|
|
|
|
|
RETURN p, a
|
|
|
|
@ -98,19 +98,19 @@
|
|
|
|
|
{:uuid uuid})))
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery edit-instance
|
|
|
|
|
"MATCH (i:instance {uuid:{uuid}})
|
|
|
|
|
SET i.name = {name},
|
|
|
|
|
i.updated_at = {updated_at}")
|
|
|
|
|
"MATCH (i:instance {uuid: $uuid})
|
|
|
|
|
SET i.name = $name,
|
|
|
|
|
i.updated_at = $updated_at")
|
|
|
|
|
(neo4j/defquery edit-property
|
|
|
|
|
"MATCH (i:instance {uuid:{instance_uuid}}),
|
|
|
|
|
(a:attribute {uuid:{attribute_uuid}})
|
|
|
|
|
MERGE (p:property {uuid:{uuid}})-[:of]->(i)
|
|
|
|
|
"MATCH (i:instance {uuid: $instance_uuid}),
|
|
|
|
|
(a:attribute {uuid: $attribute_uuid})
|
|
|
|
|
MERGE (p:property {uuid: $uuid})-[:of]->(i)
|
|
|
|
|
MERGE (p)-[:of]->(a)
|
|
|
|
|
ON CREATE SET p.created_at = {now},
|
|
|
|
|
p.updated_at = {now},
|
|
|
|
|
p.value = {value}
|
|
|
|
|
ON MATCH SET p.updated_at = {now},
|
|
|
|
|
p.value = {value}")
|
|
|
|
|
ON CREATE SET p.created_at = $now,
|
|
|
|
|
p.updated_at = $now,
|
|
|
|
|
p.value = $value
|
|
|
|
|
ON MATCH SET p.updated_at = $now,
|
|
|
|
|
p.value = $value")
|
|
|
|
|
(defn instance->prop-tuples [instance]
|
|
|
|
|
{:post [(spec/assert ::domain-instance/prop-tuple %)]}
|
|
|
|
|
(map (fn [prop]
|
|
|
|
@ -135,7 +135,7 @@
|
|
|
|
|
prop-tuples))))
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery delete
|
|
|
|
|
"MATCH (i:instance {uuid:{uuid}}),
|
|
|
|
|
"MATCH (i:instance {uuid: $uuid}),
|
|
|
|
|
(i)-[ic:of]->(s:schema),
|
|
|
|
|
(i)-[cb:created_by]->(:user)
|
|
|
|
|
OPTIONAL MATCH
|
|
|
|
@ -164,7 +164,7 @@
|
|
|
|
|
#(-> % direction :created_at)))))
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery outgoing-links
|
|
|
|
|
"MATCH (inst:instance {uuid:{uuid}}),
|
|
|
|
|
"MATCH (inst:instance {uuid: $uuid}),
|
|
|
|
|
(inst)-[link:link]->(target:instance),
|
|
|
|
|
(target)-[:of]->(schema:schema)
|
|
|
|
|
OPTIONAL MATCH
|
|
|
|
@ -175,7 +175,7 @@
|
|
|
|
|
(group-by-link-and-assoc-tags uuid outgoing-links :target))
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery incoming-links
|
|
|
|
|
"MATCH (inst:instance {uuid:{uuid}}),
|
|
|
|
|
"MATCH (inst:instance {uuid: $uuid}),
|
|
|
|
|
(inst)<-[link:link]-(source:instance),
|
|
|
|
|
(source)-[:of]->(schema:schema)
|
|
|
|
|
OPTIONAL MATCH
|
|
|
|
@ -199,8 +199,8 @@
|
|
|
|
|
(db-tag/tags-by-instance! uuid)))
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery is-starred
|
|
|
|
|
"MATCH (u:user {uuid:{user_uuid}}),
|
|
|
|
|
(i:instance {uuid:{uuid}})
|
|
|
|
|
"MATCH (u:user {uuid: $user_uuid}),
|
|
|
|
|
(i:instance {uuid: $uuid})
|
|
|
|
|
RETURN EXISTS((i)-[:starred_by]->(u)) AS starred")
|
|
|
|
|
(defn is-starred! [uuid user-uuid]
|
|
|
|
|
(-> (neo4j/exec-query! is-starred
|
|
|
|
@ -210,11 +210,11 @@
|
|
|
|
|
:starred))
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery mark-starred
|
|
|
|
|
"MATCH (i:instance {uuid:{uuid}}),
|
|
|
|
|
(u:user {uuid:{user_uuid}})
|
|
|
|
|
"MATCH (i:instance {uuid: $uuid}),
|
|
|
|
|
(u:user {uuid: $user_uuid})
|
|
|
|
|
MERGE (i)-[s:starred_by]->(u)
|
|
|
|
|
ON CREATE
|
|
|
|
|
SET s.created_at = {now}")
|
|
|
|
|
SET s.created_at = $now")
|
|
|
|
|
(defn mark-starred! [uuid user-uuid]
|
|
|
|
|
(neo4j/exec-query! mark-starred
|
|
|
|
|
{:uuid uuid
|
|
|
|
@ -222,9 +222,9 @@
|
|
|
|
|
:now (neo4j/now-str)}))
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery remove-starred
|
|
|
|
|
"MATCH (:instance {uuid:{uuid}})
|
|
|
|
|
"MATCH (:instance {uuid: $uuid})
|
|
|
|
|
-[s:starred_by]->
|
|
|
|
|
(:user {uuid:{user_uuid}})
|
|
|
|
|
(:user {uuid: $user_uuid})
|
|
|
|
|
DELETE s")
|
|
|
|
|
(defn remove-starred! [uuid user-uuid]
|
|
|
|
|
(neo4j/exec-query! remove-starred
|
|
|
|
@ -232,7 +232,7 @@
|
|
|
|
|
:user_uuid user-uuid}))
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery starred-by-user
|
|
|
|
|
"MATCH (u:user {uuid:{user_uuid}})
|
|
|
|
|
"MATCH (u:user {uuid: $user_uuid})
|
|
|
|
|
<-[s:starred_by]-
|
|
|
|
|
(i:instance)
|
|
|
|
|
RETURN i, s
|
|
|
|
|