I'm creating an app using GRANDstack on top of a Neo4j graph database and I'm struggling with writing a query that unwinds a property array, matches some IDs, pullsback names associated with the IDs and repackages them into a new array.
Essentially, I have Memory nodes (Mems) and Person nodes (Person) and their relationship is as follows: (Mems)-[WITH]->(Person). i.e. you can have a memory of something where you were WITH multiple people. The Mems nodes contain a personID property that is an array of IDs and the relationship in the graph database is built from the array of personIDs in Mems nodes that match the personIDs in the Person nodes.
The result I'm trying to achieve is like the below, however I haven't found a way to return the nicknames from the Person nodes:
The query I'm using to generate the above is below:
MATCH (m:Mem)-[WITH]->(p:Person)
WHERE m.personID IS NOT NULL
UNWIND m.personID as personID
CALL {
WITH personID
MATCH (p:Person)
WHERE personID = p.personID
RETURN p.nickname
}
RETURN m.mem, m.date, personID, p.nickname
I think it's close to what I need but I just can't figure out the last bit where I can return the nicknames associated with the personIDs. This might be something that APOC is more capable of doing?