mcollina/node-levelgraph — pull request #4 by mcollina (2013-04-28 00:07:24+00:00)
Title: Navigator

The Navigator API is a fluent API for LevelGraph.
It allows to specify joins in a much more compact way and navigate between vertexes in our graph. I am including the following example in `examples/foafNavigator.js`.

With this dataset:
```
db.put([{
subject: "matteo",
predicate: "friend",
object: "daniele"
}, {
subject: "daniele",
predicate: "friend",
object: "matteo"
}, {
subject: "daniele",
predicate: "friend",
object: "marco"
}, {
subject: "lucio",
predicate: "friend",
object: "matteo"
}, {
subject: "lucio",
predicate: "friend",
object: "marco"
}, {
subject: "marco",
predicate: "friend",
object: "davide"
});
```

Here is an example:
```
db.nav("matteo").archIn("friend").archOut("friend").
values(function(err, results) {
// prints [ 'marco', 'matteo' ]
console.log(results);
});
```

The above example match the same triples of:
```
db.join([{
subject: db.v("x0"),
predicate: 'friend',
object: 'matteo'
}, {
subject: db.v("x0"),
predicate: 'friend',
object: db.v("x1")
}], function(err, results) {
// prints:
// [ { x0: 'daniele', x1: 'marco' },
// { x0: 'daniele', x1: 'matteo' },
// { x0: 'lucio', x1: 'marco' },
// { x0: 'lucio', x1: 'matteo' } ]
console.log(results);
});
```

However, I am using two different syntaxes for results, as the user do not specify the variables names.

Here are the things that I believe are missing:
* [ ] specify a binding for a vertex e.g. a friend's name.
* [ ] start the navigation from a variable.
* [ ] specify a variable's name.
* [ ] add a flag to return the contexts, i.e. as the join/joinStream API.