Skip to content

Commit e56cde5

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 5660d45 commit e56cde5

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

314314
.bands-with-headers.csv
315-
[source, csv, filename="artists-with-headers.csv"]
315+
[source, csv, filename="bands-with-headers.csv"]
316316
----
317317
Id,Label,Name
318318
1,Band,The Beatles
@@ -322,12 +322,14 @@ Id,Label,Name
322322
----
323323

324324
.Query
325-
[source, cypher, role=test-skip]
325+
// tag::clauses_load_csv_dynamic_columns[]
326+
[source, cypher]
326327
----
327328
LOAD CSV WITH HEADERS FROM 'file:///bands-with-headers.csv' AS line
328329
MERGE (n:$(line.Label) {name: line.Name})
329330
RETURN n AS bandNodes
330331
----
332+
// end::clauses_load_csv_dynamic_columns[]
331333

332334
.Result
333335
[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
@@ -551,7 +551,7 @@ RETURN directors
551551
1+d|Rows: 2
552552
|===
553553

554-
.Match nodes dynamically using the `any()` function
554+
.Match nodes dynamically using `any()`
555555
[source, cypher]
556556
----
557557
MATCH (n:$any(["Movie", "Actor"]))
@@ -582,11 +582,14 @@ RETURN n AS nodes
582582
----
583583

584584
.Match nodes dynamically using a parameter
585+
// tag::clauses_match_dynamic_match_parameter[]
585586
[source, cypher]
586587
----
587588
MATCH (movie:$($label))
588589
RETURN movie.title AS movieTitle
589590
----
591+
// end::clauses_match_dynamic_match_parameter[]
592+
590593

591594
.Result
592595
[role="queryresult",options="header,footer",cols="1*<m"]
@@ -601,13 +604,16 @@ RETURN movie.title AS movieTitle
601604

602605

603606
.Match relationships dynamically using a variable
607+
// tag::clauses_match_dynamic_match_variable[]
604608
[source, cypher]
605609
----
606610
CALL db.relationshipTypes()
607611
YIELD relationshipType
608612
MATCH ()-[r:$(relationshipType)]->()
609613
RETURN relationshipType, count(r) AS relationshipCount
610614
----
615+
// end::clauses_match_dynamic_match_variable[]
616+
611617

612618
.Result
613619
[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
@@ -713,6 +713,7 @@ This is because a relationship can only have exactly one type.
713713
----
714714

715715
.Merge nodes and relationships using dynamic node labels and relationship types
716+
// tag::clauses_merge_dynamic_merge[]
716717
[source, cypher]
717718
----
718719
MERGE (greta:$($nodeLabels) {name: 'Greta Gerwig'})
@@ -721,6 +722,7 @@ UNWIND $movies AS movieTitle
721722
MERGE (greta)-[rel:$($relType)]->(m:Movie {title: movieTitle})
722723
RETURN greta.name AS name, labels(greta) AS labels, type(rel) AS relType, collect(m.title) AS movies
723724
----
725+
// end::clauses_merge_dynamic_merge[]
724726

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

0 commit comments

Comments
 (0)