gpt4 book ai didi

azure - 当另一个属性与某个提供的值匹配时有条件地更新一个顶点属性

转载 作者:行者123 更新时间:2023-12-03 06:09:26 25 4
gpt4 key购买 nike

我有一个带有元属性的顶点,如下所示,并且需要更新属性和附加的元属性。当 Id 与 hasId 上传递的值匹配时,需要更新数据。我可以更新以下数据的 currentDate 和 previousDate(这是一个元属性),但是我还想更新与“id”字段处于同一级别的“value”字段。我的问题是如何调整查询以更新值和日期。

`"someLabel": [
{
"id": "1234",
"value": "value",
"properties": {
"currentDate": 12/12/2023,
"previousDate": 10/10/2023
}
}
]
`

我尝试过的查询:

`g.V('9999').hasLabel('someLabel').as('a').
properties('PropertyName').
hasId('1234').
property('currentDate',12/12/2023).
property('previousDate',10/10/2023).
select('a').
property('value',<new-value>)
`

我尝试了上面提到的查询,但它不适用于更新值,因为它不是将值更新为 id 为“1234”的“new-value”,而是添加了一个新的键值对作为“value”:“新值”,正如您在此数据集中看到的那样。

`"someLabel": [
{
"id": "1234",
"value": "value",
"properties": {
"currentDate": 12/12/2023,
"previousDate": 10/10/2023
}
},
"id": "30628eea-b97a-40c9-a05f-d1e6267e8846",
"value": "new-value",
]`

预期数据集;

`"someLabel": [
{
"id": "1234",
"value": "newVal",
"properties": {
"currentDate": 12/12/2023,
"previousDate": 10/10/2023
}
}
]`

最佳答案

当另一个属性与某个提供的值匹配时更新一个顶点属性:

以下是我遵循的步骤:

  • 我使用 .hasLabel('someLabel') 按标签过滤顶点。这仅选择带有标签 someLabel 的顶点。

  • 为了根据“id”属性的值过滤顶点,我使用了 .has('id', '1234')

  • .property('value','new value') 此行修改指定顶点的 value 属性。

  • “value”属性现在将新值作为其值。

我使用的查询:

g.V()
.hasLabel('someLabel')
.has('id', '1234')
.property('value', 'new value')

运行查询之前:

输入: enter image description here

运行查询后:

输出: enter image description here

关于azure - 当另一个属性与某个提供的值匹配时有条件地更新一个顶点属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76971695/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com