-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fluent API aka Navigator #4
Conversation
This reverts commit 15ef4c6. Conflicts: index.js
@dominictarr, would you like to provide some feedback on this? |
I like the look of this, but there are somethings I do not understand. I'm not familiar with gremlin, can you link me to some docs that will help me understand what you are going for? The query seems to be, "matteo's friend's friend's"? or is it "friends of friends through matteo"? It seems that What if you provided the variable names like this: db.nav("matteo").archIn("friend", 'x0').archOut("friend", 'x1').
values(function(err, results) {
// prints:
// [ { x0: 'daniele', x1: 'marco' },
// { x0: 'daniele', x1: 'matteo' },
// { x0: 'lucio', x1: 'marco' },
// { x0: 'lucio', x1: 'matteo' } ]
console.log(results);
}); I'm also confused which node the arch is too or from. I think I find the right to left much more obvious, could it also work like this : |
a join is also a relationship on it's own, maybe it could return results in the what if the results where returned like this: [ { subject: 'daniele', object: 'marco', predicate: 'friend-of-friend' },
{ subject: 'daniele', object: 'matteo', predicate: 'friend-of-friend' },
{ subject: 'lucio', object: 'marco', predicate: 'friend-of-friend' },
{ subject: 'lucio', object: 'matteo', predicate: 'friend-of-friend' } ] then, potentially, you could materialize these, or use them as parts of other joins? |
Thanks, I needed some feedbacks here :).
The gremlin API is a common API for graph databases: https://github.com/tinkerpop/gremlin/wiki.
Actually the query is "the friend's of matteo's friends". The
The
Much better, thanks. Do you think that variable names should be mandatory?
Given the current vertex, an
Yes, that's a great idea. I have some doubts about how to expose these in the API. Is something like:
Then I believe I'll also need a |
@dominictarr In the end I went for followingmore closely the Gremlin API, and I have adoped an |
The Navigator API is a fluent API for LevelGraph, loosely inspired by Gremlin
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:
Here is an example:
The above example match the same triples of:
It allows to see just the last reached vertex:
Variable names can also be specified, like so:
Variables can also be bound to a specific value, like so:
A materialized join can also be produced, like so:
It is also possible to change the current vertex:
Here are the things that I believe are missing:
contexts
andcontextsStream
methods, giving the same result as thejoin
/joinStream
API.triples
andtriplesStream
methods, in order to get a 'materialized' stream of triples coming from a join.go
operator, to jump to another vertex.