Syncleus / Ferma

An ORM / OGM for the TinkerPop graph stack.
http://syncleus.com/Ferma
Apache License 2.0
136 stars 26 forks source link

Sort/Order By? #58

Open matanshukry opened 5 years ago

matanshukry commented 5 years ago

I'm just trying to use Ferma now (together with OrientDB), and I'm trying to find a way to sort through a result. I think there's a way using the .traverse() method, but the documentation doesn't seem to have almost any examples or information for such a thing.

How can I do that?

killje commented 5 years ago

Yes you would use .traverse() as follows

framedGraph.traverse(
    (GraphTraversalSource g) -> g.V().order().by("name")
).toList(YourVertex.class);

Note that you do not have to add GraphTraversalSource in a lambda expression, but I added this for clarity. This is a Tinkerpop class and to see the abilities like sorting you should check out the the Tinkerpop documentation: http://tinkerpop.apache.org/docs/3.3.2/reference/

The traverse function is a way to access the graph traversal build in, into Tinkerpop and gives the ability to frame the vertexes and edges to your own classes

freemo commented 4 years ago

@killje Thanks for your help on this. Reach out to me anytime if you'd like to get more involved into the project. Either way, appreciate you responding on this one.