Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions docs/modules/ROOT/pages/clauses/create.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

This page describes how to add a link:https://neo4j.com/docs/cypher-manual/current/clauses/create/[`CREATE`] clause with the `Cypher.Create` class.

To make a `CREATE` clause, first create a valid pattern using the xref:/patterns.adoc[Pattern] class:

To add the `CREATE` clause, first create a valid pattern using the xref:/patterns.adoc[Pattern] class:

[source, javascript]
----
Expand Down Expand Up @@ -39,8 +38,8 @@ This generates the following `CREATE` clause:
CREATE (this:Movie {title: "The Matrix"})
----

== Relationships

== Relationships

Relationships can be used in a match clause by creating the relevant xref:/patterns.adoc[Pattern]:

Expand All @@ -62,9 +61,9 @@ CREATE (this1:`Person`)-[this0:ACTED_IN]->(this2:`Movie`)

== Update properties

The clauses `SET` and `REMOVE` can be added with the methods `.set` and `.remove` respectively.
Add the `SET` and `REMOVE` clauses with the methods `.set` and `.remove` respectively.

`.set` take tuples of 2 elements, the first being the property to update and the second the value:
`.set` takes one or more tuples, each consisting of a property to update and a new value:

[source, javascript]
----
Expand All @@ -82,7 +81,6 @@ SET this0.title = $param0

Multiple properties can be updated by passing multiple tuples.


`.remove` takes the properties to remove:

[source, javascript]
Expand Down
3 changes: 2 additions & 1 deletion docs/modules/ROOT/pages/clauses/foreach.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

This page describes how to create a link:https://neo4j.com/docs/cypher-manual/current/clauses/foreach/[`FOREACH`] clause using the `Cypher.Foreach` class.

A `Foreach` clause takes a single variable to be used in a loop. The methods `.in` and `.do` are used to defined the list and update clauses:
A `Foreach` clause takes a single variable to be used in a loop.
Use the `.in` and `.do` methods to define the list and update clauses respectively:

[source, javascript]
----
Expand Down
3 changes: 2 additions & 1 deletion docs/modules/ROOT/pages/clauses/load-csv.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
:description: This page describes how to create `LOAD CSV` clauses.
= Load CSV

This page describes how to create link:https://neo4j.com/docs/cypher-manual/current/clauses/load-csv/[`LOAD CSV`] clauses in Cypher with Cypher Builder. To achieve this, use the `LoadCSV` class:
This page describes how to create link:https://neo4j.com/docs/cypher-manual/current/clauses/load-csv/[`LOAD CSV`] clauses in Cypher with Cypher Builder.
To achieve this, use the `LoadCSV` class:

[source, javascript]
----
Expand Down
24 changes: 15 additions & 9 deletions docs/modules/ROOT/pages/clauses/match.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

This page describes how to create a link:https://neo4j.com/docs/cypher-manual/current/clauses/match/[`MATCH`] clause with the `Cypher.Match` class.

To create a `MATCH` clause, first create a valid pattern using the xref:/patterns.adoc[Pattern] class and pass it to `Match` constructor:
To add the `MATCH` clause, first create a valid pattern using the xref:/patterns.adoc[Pattern] class and pass it to the `Match` constructor:


[source, javascript]
Expand All @@ -23,7 +23,8 @@ This generates the following `MATCH` clause:
MATCH (this:Movie)
----

Afterwards, other clauses can be added. For example:
Afterwards, other clauses can be added.
For example:

[source, javascript]
----
Expand All @@ -32,16 +33,17 @@ const matchQuery = new Cypher.Match(pattern)
.return(movie);
----

Extra match clauses can also be chained:
You can also chain extra match clauses:

[source, javascript]
----
const matchQuery = new Cypher.Match(pattern).match(pattern2).return(movie)
----


== Relationships

Relationships can be used in a match clause by creating the relevant xref:/patterns.adoc[Pattern]:
You can use relationships in a match clause by creating the relevant xref:/patterns.adoc[Pattern]:


[source, javascript]
Expand All @@ -58,6 +60,7 @@ const matchQuery = new Cypher.Match(actedInPattern)
MATCH (this0:Person)-[:ACTED_IN]->(this1:Movie)
----


== Filtering with `WHERE`

A `WHERE` clause can be appended with the `.where` method, this accepts any predicate:
Expand All @@ -74,7 +77,7 @@ MATCH (this0:Movie)
WHERE title = $param0
----

Multiple predicates can be chained by using the `.and` or `.where` method after `.where`:
You can chain multiple predicates by using the `.and` or `.where` method after `.where`:

[source, javascript]
----
Expand All @@ -90,9 +93,10 @@ WHERE this0.title = $param0
AND this0.year <> $param1
----


=== Logical filters

For more complex logical filters, the predicates `Cypher.and`, `Cypher.or`, `Cypher.not` and `Cypher.xor` can be used inside `where`:
For more complex logical filters, use the `Cypher.and`, `Cypher.or`, `Cypher.not` and `Cypher.xor` predicates inside `where`:

[source, javascript]
----
Expand All @@ -111,6 +115,7 @@ MATCH (this0:Movie)
WHERE ((this0.title = $param0 OR this0.year > $param1) AND this0.year <> $param2)
----


=== Filtering properties shorthand

`.where` also supports passing a variable and an object with variables to check for equality of multiple values in a more concise way:
Expand All @@ -130,7 +135,7 @@ WHERE (this0.id = $param0 AND this0.name = $param1)

== Optional match

The clause link:https://neo4j.com/docs/cypher-manual/current/clauses/optional-match/[`OPTIONAL MATCH`] can be created in the same manner as `MATCH` by using the class `Cypher.OptionalMatch`:
You can create the clause link:https://neo4j.com/docs/cypher-manual/current/clauses/optional-match/[`OPTIONAL MATCH`] similarly to `MATCH` by using the class `Cypher.OptionalMatch`:

[source, javascript]
----
Expand All @@ -140,7 +145,7 @@ const pattern = new Cypher.Pattern(movie, { labels: ["Movie"] });
const matchQuery = new Cypher.OptionalMatch(pattern);
----

Alternatively, an existing `Match` instance can be transformed into an `OptionalMatch` with the method `.optional()`:
Alternatively, you can transform an existing `Match` instance into an `OptionalMatch` with the method `.optional()`:

[source, javascript]
----
Expand All @@ -150,9 +155,10 @@ const pattern = new Cypher.Pattern(movie, { labels: ["Movie"] });
const matchQuery = new Cypher.Match(pattern).optional();
----


== Shortest paths

link:https://neo4j.com/docs/cypher-manual/current/patterns/shortest-paths/#shortest[Shortest paths] and its variations can be added in a Match clause with the following methods in `Cypher.Match`:
You can add link:https://neo4j.com/docs/cypher-manual/current/patterns/shortest-paths/#shortest[Shortest paths] and its variations in a Match clause with the following methods in `Cypher.Match`:

* `.shortest(k)`
* `.shortestGroups(k)`
Expand Down
9 changes: 5 additions & 4 deletions docs/modules/ROOT/pages/clauses/merge.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

This page describes how to create a link:https://neo4j.com/docs/cypher-manual/current/clauses/merge/[`MERGE`] clause with the `Cypher.Merge` class.

To create a `Merge` clause, first create a valid pattern using the xref:/patterns.adoc[Pattern] class and pass it to `Merge` constructor:
To add a `MERGE` clause, first create a valid pattern using the xref:/patterns.adoc[Pattern] class and pass it to `Merge` constructor:


[source, javascript]
Expand All @@ -24,7 +24,8 @@ This generates the following `MERGE` clause:
MERGE (this:Movie)-[:ACTED_IN]->(this1)
----

Afterwards, other clauses can be added. For example:
Afterwards, you can add other clauses.
For example:

[source, javascript]
----
Expand All @@ -40,9 +41,9 @@ WHERE this.name = $param1
return this
----

== On Create / On Match
== `ON CREATE` and `ON MATCH`

A `MERGE` statement can be followed by `ON CREATE SET` and `ON MATCH SET`, this can be achieved with the methods `onCreateSet` and `onMatchSet` respectively:
Use the methods `onCreateSet` or `onMatchSet` to add `ON CREATE SET` or `ON MATCH SET` after a `MERGE` statement:

[source, javascript]
----
Expand Down
13 changes: 7 additions & 6 deletions docs/modules/ROOT/pages/clauses/return.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

This page describes how to create a link:https://neo4j.com/docs/cypher-manual/current/clauses/return/[`RETURN`] clause with the `Cypher.Return` class.

Return clauses can be created with `new Cypher.Return`, but more commonly they are created after an existing clause, such as `MATCH`, by using the method `.return`.
You can add return clauses with `new Cypher.Return`.
However, more commonly they are added after an existing clause, such as `MATCH`, by using the method `.return`.
In both cases, the return variables can be passed as parameters:

[source, javascript]
Expand All @@ -27,16 +28,16 @@ Any expression can be passed to return, for example a function:
const returnQuery = new Cypher.Return(Cypher.round(new Cypher.Param(2.3)));
----

Which translates to:
This translates to:

[source, cypher]
----
RETURN round($param1)
----

## Aliasing results
== Aliasing results

Results can be aliased by using an array with two elements - the variable and the aliased name, which can be a string or a variable:
You can alias results by using an array with two elements - the variable and the aliased name, which can be a string or a variable:

[source, javascript]
----
Expand All @@ -51,9 +52,9 @@ This generates the following clause:
RETURN this0 AS my-node
----

## Unique results
== Unique results

`DISTINCT` can be added to `RETURN` by using the `.distinct` method:
Add `DISTINCT` to `RETURN` by using the `.distinct` method:

[source, javascript]
----
Expand Down
28 changes: 15 additions & 13 deletions docs/modules/ROOT/pages/clauses/set.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
:description: This page describes how to create `SET` clauses.
= Set

This page describes how to create link:https://neo4j.com/docs/cypher-manual/current/clauses/set/[`SET`] clauses. `SET` statements are appended to an a clause with the method `.set`.
This page describes how to create link:https://neo4j.com/docs/cypher-manual/current/clauses/set/[`SET`] clauses.
Append `SET` statements to a clause with the method `.set`.


== Update properties with `SET`

The `.set` method is used to update xref:../variables-and-params/variables.adoc#_properties[properties] of a node or relationship.

You can update xref:../variables-and-params/variables.adoc#_properties[properties] of a node or relationship with the `.set` method.
For example, to update the properties of a node:

[source, javascript]
Expand All @@ -20,7 +20,7 @@ const matchQuery = new Cypher.Match(new Cypher.Pattern(personNode, { labels: ["P
);
----

This will generate the following Cypher:
This generates the following Cypher:

[source, cypher]
----
Expand All @@ -30,7 +30,7 @@ SET
RETURN this0
----

Multiple pairs of property-expression can be passed to update multiple properties:
You can pass multiple pairs of property expressions to update multiple properties:

[source, javascript]
----
Expand All @@ -42,7 +42,7 @@ const matchQuery = new Cypher.Match(new Cypher.Pattern(personNode, { labels: ["P
);
----

This will generate the following Cypher:
This generates the following Cypher:

[source, cypher]
----
Expand All @@ -56,7 +56,8 @@ RETURN this0

=== Use `SET` to replace all node properties

To update all the properties of a node or relationship, instead of a property, pass the variable directly as the first element of the array. The second element must be a `Cypher.Map` or a variable:
To update all the properties of a node or relationship, instead of a property, pass the variable directly as the first element of the array.
The second element must be a `Cypher.Map` or a variable:

[source, javascript]
----
Expand All @@ -70,7 +71,7 @@ const matchQuery = new Cypher.Match(new Cypher.Pattern(personNode, { labels: ["P
]);
----

This generates the Cypher:
This generates the following Cypher:


[source, cypher]
Expand All @@ -97,7 +98,8 @@ SET
this1 = this0
----

==== Using operator `+=`

==== The `+=` operator

When passing a map to update a node properties with `SET`, it is possible to use the operator `+=` to add new properties, instead of replacing them:

Expand All @@ -113,7 +115,7 @@ const matchQuery = new Cypher.Match(new Cypher.Pattern(personNode, { labels: ["P
]);
----

This generates the cypher:
This generates the following Cypher:


[source, cypher]
Expand All @@ -124,7 +126,7 @@ SET
----


== `SET` with labels

== Set with labels

Set can be used to update the labels of a node or the type of a relationship. More information on xref:../../how-to/update-labels.adoc#_add_labels[How to update labels].
You can use `SET` to update the labels of a node or the type of a relationship.
For more information, see xref:../../how-to/update-labels.adoc#_add_labels[How to update labels].
6 changes: 4 additions & 2 deletions docs/modules/ROOT/pages/clauses/union.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

This page describes how to create link:https://neo4j.com/docs/cypher-manual/current/clauses/union/[`UNION`] clauses with the `Cypher.Union` class.

A union between multiple queries can be created by passing multiple clauses into a `Cypher.Union` class to combine them. Note that all clauses must be different instances, as Cypher Builder clauses cannot be reused:
Create a union between multiple queries by passing multiple clauses to the `Cypher.Union` class to combine them.
Note that all clauses must be different instances, as Cypher Builder clauses cannot be reused:

[source, javascript]
----
Expand Down Expand Up @@ -35,10 +36,11 @@ RETURN this3 AS var1

Note that this example uses the extra variable `returnVar` to make sure that all the queries return the same variable name.


== Union all

Unions remove duplicates by default.
To keep all the results, use the `.all()` method to create a `UNION ALL` clause instead:
To keep all results, use the `.all()` method to create a `UNION ALL` clause instead:

[source, javascript]
----
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/clauses/use.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

This page describes how to create a link:https://neo4j.com/docs/cypher-manual/current/clauses/use/[`USE`] clause with the `Cypher.Use` class.

To create an `Use` clause, you can pass an existing query to `Cypher.use` to prepend an `USE` statement before the query:
To create an `Use` clause, pass an existing query to `Cypher.use` to prepend a `USE` statement before the query:


[source, javascript]
Expand Down
Loading
Loading