Skip to content

Commit a6d1374

Browse files
JPryce-Aklundhgem-neo4j
authored andcommitted
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 bba7464 commit a6d1374

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
@@ -234,6 +234,7 @@ This is because a relationship can only have exactly one type.
234234
----
235235

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

246248
.Result
247249
[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
@@ -308,7 +308,7 @@ It also mitigates the risk of Cypher injection.
308308
(For more information about Cypher injection, see link:https://neo4j.com/developer/kb/protecting-against-cypher-injection/[Neo4j Knowledge Base -> Protecting against Cypher injection]).
309309

310310
.bands-with-headers.csv
311-
[source, csv, filename="artists-with-headers.csv"]
311+
[source, csv, filename="bands-with-headers.csv"]
312312
----
313313
Id,Label,Name
314314
1,Band,The Beatles
@@ -318,12 +318,14 @@ Id,Label,Name
318318
----
319319

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

328330
.Result
329331
[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
@@ -545,7 +545,7 @@ RETURN directors
545545
1+d|Rows: 2
546546
|===
547547

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

578578
.Match nodes dynamically using a parameter
579+
// tag::clauses_match_dynamic_match_parameter[]
579580
[source, cypher]
580581
----
581582
MATCH (movie:$($label))
582583
RETURN movie.title AS movieTitle
583584
----
585+
// end::clauses_match_dynamic_match_parameter[]
586+
584587

585588
.Result
586589
[role="queryresult",options="header,footer",cols="1*<m"]
@@ -595,13 +598,16 @@ RETURN movie.title AS movieTitle
595598

596599

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

606612
.Result
607613
[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
@@ -717,6 +717,7 @@ This is because the xref:planning-and-tuning/execution-plans.adoc[Cypher planner
717717
----
718718

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

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

0 commit comments

Comments
 (0)