Skip to content

Commit

Permalink
Document apoc.convert.toTree
Browse files Browse the repository at this point in the history
Fixes #1269
  • Loading branch information
vga91 authored and fbiville committed Jul 16, 2021
1 parent 70cc933 commit daa4204
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 2 deletions.
54 changes: 54 additions & 0 deletions docs/asciidoc/modules/ROOT/partials/usage/apoc.convert.toTree.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -314,4 +314,58 @@ a|
"_id":42
}
----
|===
On the other hand, we can also include everything and specify certain nodes/relationships to exclude.
For example:
[source,cypher]
----
MATCH path = (p:Person {name:'James Thompson'})-[:REVIEWED]->(movie)
WITH collect(path) AS paths
CALL apoc.convert.toTree(paths, true, {
nodes: {Movie: ['-title']},
rels: {reviewed: ['-rating']}
})
YIELD value
RETURN value;
----
.Results
[opts="header",cols="1"]
|===
| value
a|
[source,json]
----
{
"_type": "Person",
"name": "James Thompson",
"reviewed": [
{
"_type": "Movie",
"tagline": "Everything that has a beginning has an end",
"reviewed.summary": "The best of the three",
"_id": 6,
"released": 2003
},
{
"_type": "Movie",
"tagline": "Free your mind",
"reviewed.summary": "It was alright.",
"_id": 5,
"released": 2003
},
{
"_type": "Movie",
"tagline": "Welcome to the Real World",
"reviewed.summary": "Enjoyed it!",
"_id": 4,
"released": 1999
}
],
"_id": 3
}
----
|===
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ The procedure support the following config parameters:
[opts=header]
|===
| name | type | default | description
| nodes | Map<String, List<String>> | {}| properties to include for each node label e.g. `{Movie: ['title']}`
| rels | Map<String, List<String>> | {} | properties to include for each relationship type e.g. `{`ACTED_IN`: ["roles"]}`
| nodes | Map<String, List<String>> | {}| properties to include for each node label e.g. `{Movie: ['title']}` or to exclude (e.g. `{Movie: ['-title']}`).
| rels | Map<String, List<String>> | {} | properties to include for each relationship type e.g. `{`ACTED_IN`: ["roles"]}` or to exclude (e.g. `{`ACTED_IN`: ["-roles"]}`).
|===

0 comments on commit daa4204

Please sign in to comment.