Hi,
I'm writing a query but having a real hard time actually translating it effectively on the other end. I'm using neo4j to represent a folder structure - because it seems to be the perfectly logical way to do so. Example -
This way I can also attach users to appropriate folders and have figured out how to query if a user has access based on the folder chain, e.g.
OPTIONAL MATCH p = (:User { id: 1 })-[*]->(:Folder { id: 3 })
RETURN CASE WHEN p IS NULL THEN false ELSE true END as hasAccess
Additionally, I can work out the breadcrumb structure quickly and easily with something like
MATCH (:Folder { id: 5})<-[:CHILD*]-(f:Folder) RETURN f
However, what I ideally want to achieve is having a full directory structure so that in my code I can easily represent my folder structure as below
Folder 2
Folder 1
| Folder 3
| Folder 4
| Folder 5
| Folder 6
The problem is, to achieve this I'm sure I'd need the relationship, along with the node ID in each direction. Right now, this seems to be as far as I've got -
MATCH (p:Folder)-[r:CHILD]->(c:Folder) RETURN p as folder, collect(c) as children
Would appreciate any help as I slowly wrap my head around this awesome query language!