After setting the url I want to go back to my vertex to add more properties, how I can do that?
g.addV('Site')
.property(list, 'name', 'stackoverflow')
.properties('name')
.hasValue('stackoverflow')
.property('url', 'https://stackoverflow.com')
Edit: Found how to do that with gremlin but it doesn't work on cosmosdb
g.addV('Site')
.property(list, 'name', 'stackoverflow')
.properties('name')
.hasValue('stackoverflow')
.property('url', 'https://stackoverflow.com')
.next()
.element()
Anyone know any other way to achieve the same on cosmosdb?
You actually can't use next()
in a sense because next()
is iterating the traversal returning a result and you therefore move outside of Gremlin's API at that point. Unless you have your Graph
instance embedded in the same JVM, the graph element returned from next()
will be "detached" and thus immutable.
That said, it's worth noting that by calling property(list, 'name','stackoverflow')
you don't actually leave the Vertex
traverser behind so you can just string property()
calls directly after it:
g.addV('Site').
property(list, 'name', 'stackoverflow').
property('url', 'https://stackoverflow.com')
Now, if i take your Gremlin literally what you're doing there is creating a "name" property then finding that property and adding the metaproperty "url" to that and are then asking how to get back to the original parent vertex because at that point you actually are returning a VertexProperty
. Well, first note that you can set the metaproperty more directly and avoid the call to properties()
all together:
g.addV('Site').
property(list, 'name', 'stackoverflow', 'url', 'http://stackoverflow.com')