在 Azure Cosmos DB 中使用 Gremlin 重命名 属性
Rename property with Gremlin in Azure Cosmos DB
我们的一些代码库发生了变化,因此它现在期望过去具有名称为 "Sdg" 的 属性 的顶点现在具有名称为 [=] 的 属性 28=] 并用相同的值代替....简而言之,属性.
的重命名
在这一点上我已经尝试了很多,并且...我有点惊讶弄清楚如何搜索图表并在需要时进行重命名是多么困难。
我最接近的是以下查询:
g.V().has('sdg').as('vertexWithOldProperty').property('causeType', value(select('vertexWithOldProperty').select('sdg')))
...由于错误而无法工作:
Gremlin Query Compilation Error: Unable to bind to method 'value',
with arguments of type: (GraphTraversal) @ line 1, column 68. Unable
to bind to method 'property', with arguments of type: (String)
我们的想法是 运行 在图形上并记住每个具有旧值的顶点。然后我会向它们添加具有相同值的新 属性... 对于 simplicity/feasibility 我决定忽略旧值而不是删除它。
任何人都可以帮助我或引导我朝着正确的方向前进吗?
谢谢!
也许有更好的方法,但我认为这应该适合你:
g.V().has('sdg').property('causeType', values('sdg'))
如果你想删除旧的属性
g.V().has('sdg').property('causeType', values('sdg')).properties('sdg').drop()
我们的一些代码库发生了变化,因此它现在期望过去具有名称为 "Sdg" 的 属性 的顶点现在具有名称为 [=] 的 属性 28=] 并用相同的值代替....简而言之,属性.
的重命名在这一点上我已经尝试了很多,并且...我有点惊讶弄清楚如何搜索图表并在需要时进行重命名是多么困难。
我最接近的是以下查询:
g.V().has('sdg').as('vertexWithOldProperty').property('causeType', value(select('vertexWithOldProperty').select('sdg')))
...由于错误而无法工作:
Gremlin Query Compilation Error: Unable to bind to method 'value', with arguments of type: (GraphTraversal) @ line 1, column 68. Unable to bind to method 'property', with arguments of type: (String)
我们的想法是 运行 在图形上并记住每个具有旧值的顶点。然后我会向它们添加具有相同值的新 属性... 对于 simplicity/feasibility 我决定忽略旧值而不是删除它。
任何人都可以帮助我或引导我朝着正确的方向前进吗?
谢谢!
也许有更好的方法,但我认为这应该适合你:
g.V().has('sdg').property('causeType', values('sdg'))
如果你想删除旧的属性
g.V().has('sdg').property('causeType', values('sdg')).properties('sdg').drop()