Most efficient way to model file system paths


I’m new to graph databases and have started playing with Cayley to try and see if it is the best choice for a project where I need to store filesystem path hierarchies with metadata attached at each node. I’ve started out by using the in-memory graph in Go and modeling against a file system node struct. But one thing I am not able to wrap my head around is the properly efficient approach to indexing straight to a particular path. I had hoped to avoid encoding the entire path at each node because that would make branch renames very annoying.

So given /path/to/some/dir/A, I would have to start at the ‘path’ root and iterate the outs until “A”? Is this an efficient usage of a graphdb for this problem? Would this entire recursive query end up running server-side with only one roundtrip?


To be more specific about my project, I need to model something like:

type Template struct {
    Name string
    Date time.Time
    Trees []*Node

type Node struct {
    Name string
    Mode int
    Type int

func (n *Node) Path() string {
    // return /path/to/node

There would be many templates containing 1 or more trees of filesystem hierarchies.