1
json 결과에 매핑하려는 중첩 된 has_many 관계가 있습니다. 이 사이퍼에 중첩 된 has_many 관계
MATCH (a:Person { name: "Andres" })-[:FATHER_OF]->(child)
RETURN
{name:a.name, kids:collect(child.name)} as document
이 경우이
MATCH (a:Person { name: "Andres" })-[:FATHER_OF]->(child)-[:has_read]->(book)-[:has_chapter]->(chapter)
RETURN
{name:a.name, kids:collect({"name":child.name, has_read:collect(book)})} as document
같은 것을 내가 대신 원하는이다
중첩 된 아니에요 제외하고블로그에서 다음의 예는, 내가하고 싶은 일의 종류를 보여줍니다 I 다음과 같은 구조의 json 객체를 반환하고 싶습니다.
{
"name": "Andres"
"kids": [
{
"name":"Bob"
"has_read": [
{
"name":"Lord of the Rings",
"chapters": ["chapter1","chapter2","chapter3"]
},
{
"name":"The Hobbit",
"chapters": ["An unexpected party","Roast mutton"]
}
]
},
{
"name":"George"
"has_read": [
{
"name":"Lord of the Rings",
"chapters": ["chapter1","chapter2","chapter3"]
},
{
"name":"Silmarillion",
"chapters": ["chapter1","chapter2"]
}
]
}
]
}
"수집 ({이름 : 아이. name, has_read : books}) "이전에 구문을 수집하는 것을 보지 못했습니다. 어디에서 문서화되어 있습니까? –
@BobB - http://neo4j.com/docs/stable/query-aggregation.html#aggregation-collect – OpenDataAlex