Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #1269: Document apoc.convert.toTree #2036

Merged
merged 3 commits into from
Jul 16, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
53 changes: 53 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,57 @@ a|
"_id":42
}
----
|===

On the other hand, we can also include all nodes/rels exlcuding excluding some of them.
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"]}`).
|===