I am using a graph db (neo4j) and cypher. My goal for this query is to first match every Pin that a given User has PINNED, and then count the number of LIKES each of those pins has. Currently I am able to return the total number of likes between all the pins, but this information doesn't help me when there are several pins. For example, if I run this query in my DB right now and there are 2 nodes with 2 likes and 3 likes respectively, my query will return "5". So I have no way of knowing how many of the likes belong to each pin. How can I write this query such that I get the number of LIKES for each pin?
MATCH (u:User {lastName:"Example"})-[:PINNED]->(z:Pin)
WITH collect(z) as cs
MATCH (:User)-[:LIKES]->(y:Pin)
WHERE (y) in cs
MATCH (a:User)-[r:LIKES]->(y)
RETURN COUNT(r), y