Hello
Im currently working on a cypher query and have questions about automatic mapping.
As an example I will use this part of a query I'm working on:
MATCH (c:Community)
WITH c {
.*,
__nodeLabels__:labels(c),
Community_DE_Language: [(c)-[:DE]->(cl:Language)|cl{.*, __nodeLabels__:labels(cl)}],
Community_FR_Language: [(c)-[:FR]->(cl:Language)|cl{.*, __nodeLabels__:labels(cl)}],
Community_IT_Language: [(c)-[:IT]->(cl:Language)|cl{.*, __nodeLabels__:labels(cl)}],
Community_EN_Language: [(c)-[:EN]->(cl:Language)|cl{.*, __nodeLabels__:labels(cl)}]
} as community
RETURN community
As it stands, it works just fine. After returning this from the query I use neo4jMappingContext.getRequiredMappingFunctionFor(Community.class) to generate the appropriate Java object.
I wonder though if it's at all possible to somehow "collect" the relations and their nodes (in this example "cRel" and "clTest") and append them inside the "WITH" clause.
I imagined that somewhat like this:
MATCH (c:Community)-[cRel]->(cltest:KnowledgeEntryLanguage)
WITH c {
.*,
__nodeLabels__:labels(c),
__relationships__:collect(cRel),
__relationshipNodes__:collect(cltest)
} as community
RETURN community
Of course in my example this isn't exactly needed, but it would prove handy on other parts of our code.
EDIT:
This question originally stems from the last query in this part of the SDN Documentation: Spring Data Neo4j