Search code examples
javaruby-on-railsorientdb

OrientDB: How to remove specific lightweight edge?


I am using ruby on rails' gem oriented, which allows you to use the Java API to interface with Orient's database.

Say I have three vertices v0 (rid #10:0), v1 (rid #10:1) and v2 (rid #10:2), and then I add edges connecting them like so:

connection = Oriented.connection
graph = connection.graph

v0 = graph.getVertex("#10:0")
v1 = graph.getVertex("#10:1")
v2 = graph.getVertex("#10:2")

graph.addEdge(nil, v0, v1, 'owns')
graph.addEdge(nil, v0, v2, 'owns')

So now my database looks like this:

rid   | in_owns | out_owns
------|---------|-------------
#10:0 |         | #10:1, #10:2
#10:1 | #10:0   |
#10:2 | #10:0   |

And now I would like to remove the edge between #10:0 and #10:1, preferably using Java's API to do it, which oriented seems to support (couldn't find a way to run SQL queries inside a transaction)


Solution

  • Lightweight edges are like regular edges from TInkerPop Java API, so when you browse them and you want to delete one of it, use the TinkerPop API:

    OrientEdge.remove();