Search code examples
graphorientdbgremlin

Updating node on Orientdb with gremlin query


I am having trouble updating properties in the nodes in Orientdb using gremlin with the following code. Both property and setProperty doesn't seem to work for OrientDB.

g.V('@rid','#100').property('text','new updated text'))
g.V('@rid','#100').setProperty('text','new updated text'))

However, I was able to update the node using SQL-like query that OrientDB supports.

update classname set text = 'new updated text' where @rid = #100

But I need to update the nodes with using gremlin query in OrientDB. I looked into gremlin query tutorials and most suggest that .property('text','new updated text') should work.

Is it that OrientDB only supports limited gremlin queries and not all?


Solution

  • You seem to have a bit of a mix between TinkerPop 2.x and 3.x syntax. My memory is really hazy about TinkerPop 2.x but I think you just need to iterate your traversal and use the second syntax. Therefore, assuming g.V('@rid','#100') returns a vertex you should just do:

    g.V('@rid','#100').next().setProperty('text','new updated text'))