Update a vertex property when another sibling property matches a certain value

Thakkar, Meet S 0 Reputation points
2023-08-29T18:31:04.4766667+00:00

So I'm running the following query on a vertex and the goal is to update meta properties and a vertex property and that matches the provided values on a sibling vertex property. I'm able to update the meta properties but not the sibling property.

g.V('1').hasLabel('label').properties('FirstSet').has('id','1').property('date','1/1/2023')

“FirstSet”: [
  {
    "id": "1",
    "value": "1",
    "label": "label",
    "properties": {
      "Date": "12/12/2023"
    }
  },
  {
    "id": "2",
    "value": "value1",
    "label": "label",
    "properties": {
      "Date": "1/1/2023"
    }
  }
]

Using this I'm able to update the values inside the "properties" object that is date, but I'd also like to update the value field that is after the id value, so basically where id is 1 update the value and date to the new provided values.

g.V('1').hasLabel('label').properties('FirstSet').has('id','1').property('value','newValue')

I tried the query above but it adds a new field 'value' on the meta properties instead of updating the existing value property, which is very obvious to happen

RESULTS RECEIVED:

“FirstSet”: [
  {
    "id": "1",
    "value": "1",
    "label": "label",
    "properties": {
      "Date": "12/12/2023",
	  "value" : "newValue"
    }
  },
  {
    "id": "2",
    "value": "value1",
    "label": "label",
    "properties": {
      "Date": "1/1/2023"
    }
  }
]

EXPECTED RESULT:

“FirstSet”: [
  {
    "id": "1",
    "value": "newValue",
    "label": "label",
    "properties": {
      "Date": "12/12/2023"
    }
  },
  {
    "id": "2",
    "value": "value1",
    "label": "label",
    "properties": {
      "Date": "1/1/2023"
    }
  }
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
40,280 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.