Skip to content

Commit 1c27d45

Browse files
Add cheat sheet tags for dynamic labels/types (#1117)
(Also fixes 2 minor errors) Corresponding Cheat sheet PR: neo4j/docs-cheat-sheet#202
1 parent 315c3eb commit 1c27d45

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

modules/ROOT/pages/clauses/create.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ This is because a relationship can only have exactly one type.
235235
----
236236

237237
.Create nodes and relationships using dynamic node labels and relationship types
238+
// tag::clauses_create_dynamic_create[]
238239
[source, cypher]
239240
----
240241
CREATE (greta:$($nodeLabels) {name: 'Greta Gerwig'})
@@ -243,6 +244,7 @@ UNWIND $movies AS movieTitle
243244
CREATE (greta)-[rel:$($relType)]->(m:Movie {title: movieTitle})
244245
RETURN greta.name AS name, labels(greta) AS labels, type(rel) AS relType, collect(m.title) AS movies
245246
----
247+
// end::clauses_create_dynamic_create[]
246248

247249
.Result
248250
[role="queryresult",options="footer",cols="4*<m"]

modules/ROOT/pages/clauses/load-csv.adoc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ It also mitigates the risk of Cypher injection.
309309
(For more information about Cypher injection, see link:https://neo4j.com/developer/kb/protecting-against-cypher-injection/[Neo4j Knowledge Base -> Protecting against Cypher injection]).
310310

311311
.bands-with-headers.csv
312-
[source, csv, filename="artists-with-headers.csv"]
312+
[source, csv, filename="bands-with-headers.csv"]
313313
----
314314
Id,Label,Name
315315
1,Band,The Beatles
@@ -319,12 +319,14 @@ Id,Label,Name
319319
----
320320

321321
.Query
322-
[source, cypher, role=test-skip]
322+
// tag::clauses_load_csv_dynamic_columns[]
323+
[source, cypher]
323324
----
324325
LOAD CSV WITH HEADERS FROM 'file:///bands-with-headers.csv' AS line
325326
MERGE (n:$(line.Label) {name: line.Name})
326327
RETURN n AS bandNodes
327328
----
329+
// end::clauses_load_csv_dynamic_columns[]
328330

329331
.Result
330332
[role="queryresult",options="header,footer",cols="1*<m"]

modules/ROOT/pages/clauses/match.adoc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ RETURN directors
546546
1+d|Rows: 2
547547
|===
548548

549-
.Match nodes dynamically using the `any()` function
549+
.Match nodes dynamically using `any()`
550550
[source, cypher]
551551
----
552552
MATCH (n:$any(["Movie", "Actor"]))
@@ -577,11 +577,14 @@ RETURN n AS nodes
577577
----
578578

579579
.Match nodes dynamically using a parameter
580+
// tag::clauses_match_dynamic_match_parameter[]
580581
[source, cypher]
581582
----
582583
MATCH (movie:$($label))
583584
RETURN movie.title AS movieTitle
584585
----
586+
// end::clauses_match_dynamic_match_parameter[]
587+
585588

586589
.Result
587590
[role="queryresult",options="header,footer",cols="1*<m"]
@@ -596,13 +599,16 @@ RETURN movie.title AS movieTitle
596599

597600

598601
.Match relationships dynamically using a variable
602+
// tag::clauses_match_dynamic_match_variable[]
599603
[source, cypher]
600604
----
601605
CALL db.relationshipTypes()
602606
YIELD relationshipType
603607
MATCH ()-[r:$(relationshipType)]->()
604608
RETURN relationshipType, count(r) AS relationshipCount
605609
----
610+
// end::clauses_match_dynamic_match_variable[]
611+
606612

607613
.Result
608614
[role="queryresult",options="header,footer",cols="2*<m"]

modules/ROOT/pages/clauses/merge.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,7 @@ This is because the xref:planning-and-tuning/execution-plans.adoc[Cypher planner
718718
----
719719

720720
.Merge nodes and relationships using dynamic node labels and relationship types
721+
// tag::clauses_merge_dynamic_merge[]
721722
[source, cypher]
722723
----
723724
MERGE (greta:$($nodeLabels) {name: 'Greta Gerwig'})
@@ -726,6 +727,7 @@ UNWIND $movies AS movieTitle
726727
MERGE (greta)-[rel:$($relType)]->(m:Movie {title: movieTitle})
727728
RETURN greta.name AS name, labels(greta) AS labels, type(rel) AS relType, collect(m.title) AS movies
728729
----
730+
// end::clauses_merge_dynamic_merge[]
729731

730732
.Result
731733
[role="queryresult",options="footer",cols="3*<m"]

0 commit comments

Comments
 (0)