Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gremlin update existing property

How do I update an existing property of a node in a graph using Gremlin?

The following method creates two properties "timestamp" with 2 different values, instead of updating the existing property "timestamp":

ContentGraph.g.addV('Filter').property('timestamp', new Date());
ContentGraph.g.V().hasLabel('Filter').property('timestamp', new Date());
like image 804
Auricopter Avatar asked Feb 24 '19 17:02

Auricopter


1 Answers

I am not sure which graph DB you are using but some, such as Amazon Neptune, have a default cardinality of set. You can override that cardinality setting using the Cardinality.single enum.

ContentGraph.g.addV('Filter').property('timestamp', new Date());
ContentGraph.g.V().hasLabel('Filter').property(single,'timestamp', new Date());

Hope that helps, Kelvin

like image 185
Kelvin Lawrence Avatar answered Sep 21 '22 18:09

Kelvin Lawrence