Skip to content

Commit 48739bc

Browse files
authored
Merge branch 'main' into 3-dev
2 parents 0f794ef + f017f1d commit 48739bc

File tree

6 files changed

+24
-30
lines changed

6 files changed

+24
-30
lines changed

docs/modules/ROOT/content-nav.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
* Getting started
33
** xref:getting-started/installation.adoc[]
44
** xref:getting-started/querying.adoc[]
5+
** xref:getting-started/connecting-to-neo4j.adoc[]
56
** xref:getting-started/filters-and-projections.adoc[]
67
** xref:getting-started/relationships-and-advanced-filtering.adoc[]
7-
** xref:getting-started/connecting-to-neo4j.adoc[]
88
* Building queries
99
** Clauses
1010
*** xref:clauses/match.adoc[]

docs/modules/ROOT/pages/getting-started/connecting-to-neo4j.adoc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ CREATE(:Movie {title: "The Terminal"})
2727
----
2828

2929
== Initialize the driver
30-
Add the following lines to the JavaScript file created in the xref:/getting-started/installation.adoc[Installation] step to initialize the driver:```
31-
32-
I think the link to the JS manual makes it a bit confusing here because the instructions are also featured below, so if that makes sense, removing that notion can be a bit more clarifying.
33-
30+
Add the following lines to the JavaScript file created in the xref:/getting-started/installation.adoc[Installation] step to initialize the driver:
3431

3532
[source, javascript]
3633
----

docs/modules/ROOT/pages/getting-started/filters-and-projections.adoc

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ It should return only the movie "The Matrix", released in 1999.
1818

1919
== Filtering
2020

21-
Adding filters to a `MATCH` clause has a similar process to how you add the `RETURN` clause.
22-
Here is how you should proceed:
21+
Adding filters to a `MATCH` clause is similar to how you add the `RETURN` clause:
2322

2423
. Use the method `.where`:
2524
+
@@ -31,38 +30,41 @@ const clause = new Cypher.Match(new Cypher.Pattern(movieNode, { labels: ["Movie"
3130
.return(movieNode);
3231
----
3332

34-
. Then, add a condition to the filter:
33+
. Then, to add a condition to the filter, for example:
3534
+
3635
[source, cypher]
3736
----
3837
m.title = "The Matrix"
3938
----
4039

41-
. Use the function `Cypher.eq()` to add the property `title` of the `movieNode` variable and compare them with an equality operator (`=`):
40+
.. Use the function `Cypher.eq()` to add an **eq**uality operator (`=`) in where:
41+
+
42+
[source, javascript]
43+
----
44+
.where(Cypher.eq())
45+
----
46+
47+
.. `Cypher.eq()` takes two arguments to compare. For the first one, add the property `title` of `movieNode`:
4248
+
4349
[source, javascript]
4450
----
4551
movieNode.property("title")
4652
----
4753

48-
. Use the `Cypher.Param` class to add the string `"The Matrix"` as a parameter.
49-
It will replace the value with a suitable placeholder:
54+
.. The second argument is the value to compare (`"The Matrix"`). Pass it as a link:https://neo4j.com/docs/cypher-manual/current/syntax/parameters/[Parameter] with `new Cypher.Param`
5055
+
5156
[source, javascript]
5257
----
5358
new Cypher.Param("The Matrix")
5459
----
5560
+
56-
[NOTE]
57-
====
58-
Though it is possible to inject the string value into the query, it is good practice to use link:https://neo4j.com/docs/cypher-manual/current/syntax/parameters/[Parameters].
59-
====
61+
`Cypher.Param` will replace the string with a suitable `$param`, to avoid injecting values directly into the generated Cypher.
6062

61-
. Finally, your `MATCH` clause should now look like this:
63+
. Your `MATCH` clause should now look like this:
6264
+
6365
[source, javascript]
6466
----
65-
const clause = new Cypher.Match(new Cypher.Pattern(movieNode, { labels: ["Movie"] }))
67+
const clause = new Cypher.Match(new (movieNode, { labels: ["Movie"] }))
6668
.where(Cypher.eq(movieNode.property("title"), new Cypher.Param("The Matrix")))
6769
.return(movieNode);
6870
----

docs/modules/ROOT/pages/getting-started/installation.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ This guide shows how to start using Cypher Builder by setting up a Node.js proje
1919
npm init es6 -y
2020
----
2121
+
22-
Note that these examples use ES6 modules, but CommonJS modules can be used as well.
22+
Note that these examples use ES modules, but CommonJS modules can be used as well.
2323

2424

2525
. Install link:https://www.npmjs.com/package/@neo4j/cypher-builder[`@neo4j/cypher-builder`] and add it to the dependencies list with the following command:

docs/modules/ROOT/pages/getting-started/querying.adoc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ import Cypher from "@neo4j/cypher-builder";
6969
const movieNode = new Cypher.Node();
7070
7171
const matchPattern = new Cypher.Pattern(movieNode, { labels: ["Movie"] });
72-
7372
const clause = new Cypher.Match(matchPattern).return(movieNode);
7473
7574
const { cypher } = clause.build();
@@ -89,5 +88,3 @@ RETURN this0
8988
====
9089
Note that `this0` is an autogenerated name for the Node variable created by the Cypher Builder.
9190
====
92-
93-
To create more complex queries, refer to the tutorial on xref:/getting-started/filters-and-projections.adoc[Filtering and projection].

docs/modules/ROOT/pages/getting-started/relationships-and-advanced-filtering.adoc

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,19 @@ Querying it on the Movies Dataset should prompt this result:
2929
| "The Replacements" | "Pain heals, Chicks dig scars... Glory lasts forever" | 2000 | ["Shane Falco"]
3030
|===
3131

32-
Though the `Cypher.Match` statement accepts a `Cypher.Node` variable, this is a shorthand for very simple queries involving a single node.
33-
For more complex `MATCH` statements, like the one in this tutorial, you should define a *Pattern* when establishing relationships.
34-
3532
== Pattern creation
3633

37-
These are the steps you should follow to define a more complex pattern:
34+
To define a more complex pattern:
3835

39-
. Define the elements of the pattern.
36+
. Define the variables of the pattern.
4037
Relationships, just like nodes, are variables that can be created and reused across your query:
4138
+
4239
[source, javascript]
4340
----
44-
const actedIn = new Cypher.Relationship();
45-
41+
const movieNode = new Cypher.Node();
4642
const personNode = new Cypher.Node();
43+
44+
const actedIn = new Cypher.Relationship();
4745
----
4846
+
4947
So far, the relationship is not connected to the nodes.
@@ -60,7 +58,7 @@ const pattern = new Cypher.Pattern(movieNode, { labels: ["Movie"] })
6058
+
6159
Note that, in Cypher Builder, patterns work similarly to Cypher, with each element of the chain being either a relationship or a node.
6260

63-
. Switch the `movieNode` variable for the `pattern` in the `MATCH` clause:
61+
. Use the `pattern` variable in the `MATCH` clause:
6462
+
6563
[source, javascript]
6664
----
@@ -185,7 +183,7 @@ Make sure to double-check whether all variables refer to the correct param and n
185183

186184
== Projection aliases
187185

188-
Lastly, here is how you can add projection aliases:
186+
Lastly, you can add projection aliases:
189187

190188
. To return `r.roles` aliased as `actingRoles`, add `roles` to the list of properties:
191189
+

0 commit comments

Comments
 (0)