I am trying to check if vertex exists before creating a new one or updating existing one:
x = g.V().has('name','xyz').hasNext() // /search 1
if ( x != true ){
g.V().addVertex( 'name', 'xyz' ) }
g.V().has('name','xyz').property('x','1') // search 2
The example has 2 searches for element with name = xyz; I would like to save first search to a variable and refer to it later.
However, if I try to save search, it does not get saved:
gremlin> x = g.V().has('name','xyz')
==>v[40964336]
gremlin> x
gremlin>
What is the way to avoid having two searches in this example? - thank you!!!