I have a person node in my graph:
CREATE (:Person {id: "1" name:"foo"})
Which can optionally have one or more phone numbers associated with it. I then do the following to query the person:
MATCH (p:Person)
WHERE p.id = "1"
WITH p
MATCH p-[?:PHONE]->ph
RETURN p.id, p.name, COLLECT([ph.id, ph.number]) AS phones
This works fine when the person has phone numbers:
"1", "foo", [["p1", "111-1111"], ["p2", "111-1112"]]
But in the case that the person doesn't have any phone numbers, I get the following result:
"1", "foo", [[null, null]]
How can I return the the following instead if there are no phone numbers?
"1", "foo", null