change parameter syntax

neo4j-4
Josha von Gizycki 4 years ago
parent 1f42aad23e
commit 72def1be2a

@ -3,7 +3,7 @@
(neo4j/defquery findy-by-schema
"MATCH (a:attribute)-->(s:schema)
WHERE s.uuid = {uuid}
WHERE s.uuid = $uuid
RETURN a
ORDER BY a.name")
(defn find-by-schema! [schema-uuid]
@ -14,8 +14,8 @@
(neo4j/defquery with-name-in-schema
"MATCH (a:attribute)-[:of]->(s:schema)
WHERE a.name = {name}
AND s.uuid = {schema_uuid}
WHERE a.name = $name
AND s.uuid = $schema_uuid
RETURN a")
(defn with-name-in-schema! [matching-name schema-uuid]
(-> (neo4j/exec-query! with-name-in-schema
@ -25,16 +25,16 @@
:a))
(neo4j/defquery create-new
"MATCH (s:schema {uuid:{schema_uuid}}),
(u:user {uuid:{user_uuid}})
"MATCH (s:schema {uuid: $schema_uuid}),
(u:user {uuid: $user_uuid})
CREATE (a:attribute)
CREATE (a)-[:created_by]->(u)
CREATE (a)-[:of]->(s)
SET a.type = {type}
SET a.name = {name}
SET a.uuid = {attribute_uuid}
SET a.required = {required}
SET a.created_at = {created_at}")
SET a.type = $type
SET a.name = $name
SET a.uuid = $attribute_uuid
SET a.required = $required
SET a.created_at = $created_at")
(defn create-new! [attr schema-uuid user-uuid]
(neo4j/exec-query!
create-new
@ -46,10 +46,10 @@
(neo4j/defquery edit
"MATCH (a:attribute)
WHERE a.uuid = {uuid}
SET a.type = {type}
SET a.name = {name}
SET a.required = {required}")
WHERE a.uuid = $uuid
SET a.type = $type
SET a.name = $name
SET a.required = $required")
(defn edit! [attr]
(neo4j/exec-query!
edit
@ -57,7 +57,7 @@
(neo4j/defquery delete-by-uuid
"MATCH (a:attribute)-[c]-()
WHERE a.uuid = {uuid}
WHERE a.uuid = $uuid
DELETE c, a")
(defn delete-by-uuid! [uuid]
(neo4j/exec-query!
@ -65,7 +65,7 @@
{:uuid uuid}))
(neo4j/defquery required
"MATCH (a:attribute)-[:of]->(s:schema {uuid:{schema_uuid}})
"MATCH (a:attribute)-[:of]->(s:schema {uuid: $schema_uuid})
WHERE a.required = 1
RETURN a
ORDER BY a.name")
@ -84,7 +84,7 @@
first))
(neo4j/defquery find-by-instance
"MATCH (i:instance {uuid:{instance_uuid}}),
"MATCH (i:instance {uuid: $instance_uuid}),
(i)-[:of]->(s:schema),
(a:attribute)-[:of]->(s)
RETURN a

@ -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

@ -12,7 +12,7 @@
::name]))
(neo4j/defquery tags-by-instance
"MATCH (i:instance {uuid:{uuid}})-[:tagged_with]->(t:tag)
"MATCH (i:instance {uuid: $uuid})-[:tagged_with]->(t:tag)
RETURN t
ORDER BY t.name")
(defn tags-by-instance! [instance-uuid]
@ -22,11 +22,11 @@
{:uuid instance-uuid})))
(neo4j/defquery merge-tag
"MATCH (i:instance {uuid:{instance_uuid}}),
(u:user {uuid:{user_uuid}})
MERGE (t:tag {name:{name}})-[:created_by]->(u)
ON CREATE SET t.uuid = {uuid},
t.created_at = {now}
"MATCH (i:instance {uuid: $instance_uuid}),
(u:user {uuid: $user_uuid})
MERGE (t:tag {name: $name})-[:created_by]->(u)
ON CREATE SET t.uuid = $uuid,
t.created_at = $now
MERGE (i)-[:tagged_with]->(t)")
(spec/def ::merge-tag-tuple
(spec/keys :req-un [::specs/instance_uuid
@ -59,9 +59,9 @@
(merge-tag-tuples tags instance-uuid user-uuid)))
(neo4j/defquery remove-tag
"MATCH (i:instance {uuid:{instance_uuid}})
"MATCH (i:instance {uuid: $instance_uuid})
-[c:tagged_with]->
(t:tag {uuid:{uuid}})
(t:tag {uuid: $uuid})
DELETE c")
(defn remove-tag! [uuid instance-uuid]
(neo4j/exec-query! remove-tag

Loading…
Cancel
Save