Shireesh
Shireesh

Reputation: 61

How to update several vertices with same property in Gremlin

I have a set of vertices which have the same property 'TYPE'. How to update this property for all the given set of vertices.

Upvotes: 5

Views: 1269

Answers (1)

Marko A. Rodriguez
Marko A. Rodriguez

Reputation: 1702

You can iterate through all your vertices and update their type property using a sideEffect. For example:

g.V.sideEffect{it.setProperty('TYPE',newTypeValue)}.iterate()

If you have a predefined set of vertices, you can do this:

mySetOfVertices._().sideEffect{it.setProperty('TYPE',newTypeValue)}.iterate()

Or...in pure Groovy:

mySetOfVertices.each{ it.setProperty('TYPE',newTypeValue) }

Upvotes: 8

Related Questions