I need to add a new Vertex with an Edge. My code is something like:
g.V().addV("Vertex").addE("MyEdge").to(V().has("OtherVertex", "name", "test"))
If V().has("OtherVertex", "name", "test")
return a Vertex, everything works fine. My problem is if the OtherVertex
doesn't exist, Gremlin add the new Vertex without edges. I would like to add the new Vertex only if I can create the Edge.
I am using Gremlin-server for developing. My guess is, I could try to use Transactions
, but I am not sure if AWS Neptune support it now.
Any suggestion? Thanks.
I think, avoiding transactions, I realize that I can select OtherVertex
first. If it doesn't exist, the query will not create a new Vertex:
g.V().has("OtherVertex", "name", "test").as('t').addV("Vertex").as('v').addE("MyEdge").from('v').to('t')