0

for example navigating to localhost/root/parent1/child3/node will show a json document under this path or localhost/root/parent2/ will show a json document with an array of links to it's children ['localhost/root/parent2/child1', 'localhost/root/parent2/child2/', ...]

I need a way to quickly traverse all nodes, do filters like localhost/root?date='05/27/2014' which will return a tree of documents where a node has a modified date matching the date provided. so localhost/root?date='05/27/2014'/parent2/ will list only children with modified date matching 05/27/2014

Would a graph database be best for this or MongoDB? This doesn't seem like an overly custom feature, it's almost like an REST HATEOAS link relationship.

Community
  • 1
  • 1
KJW
  • 15,035
  • 47
  • 137
  • 243

1 Answers1

1

A basic urls for each node:

`/api/tree/{id}`
`/api/tree/id:{id}` - if you want to use alternative syntaxes as well

An alternative url should be something like this, but it is not necessary to use this one, it is better to use the link relations for traversing the tree.

/api/v1/tree/rootNode/level1Child/level2Child/level3Child/...

The data part of the response should be something like this:

{
    id: "sthfh3rfasvdfn",
    name: "rootNode",
    childNodes: [
        {
            id: "svfwgf3z4ervd",
            name: "level1Child",
            childNodes: [
                {
                    id: "bvniw3k2rn238dgi",
                    name: "level2Child",
                    childNodes: [
                        {
                            ...
                        }
                    ]
                }
            ]
        }
    ]
}

Or instead of the name you can use the index.

The controller part of the hypermedia response should contain IANA link relations:

  • self for the actual node
  • up or collection for the parent node
  • item for each of the child nodes
  • first, last, next, previous by pagination of child nodes

Try a hypermedia json format for the responses, for example JSON-LD or HAL+JSON.

inf3rno
  • 24,976
  • 11
  • 115
  • 197