CosmosDB plot: how to update the value of a multi-valued vertex property using gremlin?

Suppose my request is:

g.addV('employee').property('id', 'john').property('country', 'USA').property('country', 'India')

      

which adds the country of ownership with two meanings, for example USA and India.

[
 {
  "id":"john",
  "label":"employee",
  "type":"vertex",
  "properties":{
                "country":[
                          {
                           "id":"5dc2aaf6-cb11-4d4a-a2ce-e5fe79d28c80",
                           "value":"USA"
                          },
                          {
                           "id":"fcf4baf6-b4d5-45a3-a4ba-83a859806aef",
                           "value":"India"
                          }
                          ]
                }
 }
]

      

Now I want to change one of the existing values. For example "India" to "China" .

What would be the request for this?

+3


source to share


3 answers


In one request, it's simple:



g.V().has('id', 'john').
  sideEffect(properties('country').hasValue('India').drop()).
  property(list, 'country', 'China')

      

+3


source


First we can reset the value for "India" and then add "China" . I am testing it with the following request on my side, it works correctly.



g.V().has('id', 'john').properties('country').hasValue('India').drop()
g.V().has('id', 'john').property(list, 'country', 'China')

      

+2


source


gV (). has ('employee', 'id', 'john'). property ('country', 'China')

0


source







All Articles