Fdiazreal
Fdiazreal

Reputation: 881

Navigate through a "chain" in OrientDB

Background:

I am new in OrientDB, I will test it in Java for some days to see if it is the DB that I need.

Context:

Suppose you have something similar to a LinkedList, but made with vertex and (O) edges (-):

O - O - O - O - O - O - O - O

Each vertex has a field called "name" and an edge labeled "bestFriend".

Question:

I need to print the names of all of the vertex of the "chain". Is there any way or API method to navigate through the entire list in a fast way, with a complexity < O(n)?

Thank you

Upvotes: 2

Views: 254

Answers (1)

Lvca
Lvca

Reputation: 9049

Try something like:

select name from ( traverse out('bestFriend') from #10:44 )

Assuming #10:44 is the root vertex's id.

Upvotes: 1

Related Questions