gremlin - 如何用另一个顶点的 属性 更新顶点 属性

gremlin - how to update vertex property with another vertex's property

测试数据:

vertex A has property 'a' value '1'
vertex B has outEdge  'e' to A
vertex B had property 'b' value '2'

如何将 'a' 更新为 'b' 在本例中为“2”的值?

我已经试过了,但没有用

g.V().hasLabel('A').property('a', inE('e').outV().project('b').by('b').unfold())

使用...构建图表

gremlin> g.addV('A').property('a','1').as('a').
   ......1>   addV('B').property('b','2').as('b').
   ......2>   addE('e').from('b').to('a')

gremlin> g.V().valueMap()
==>[a:[1]]
==>[b:[2]]

您可以使用 A 中的值来更新 B,如下所示(这是一种编写查询的方法,还有其他方法)

gremlin> g.V().hasLabel('B').as('b').V().hasLabel('A').property('a',select('b').values('b'))
==>v[42790]

gremlin> g.V().valueMap()
==>[a:[2]]
==>[b:[2]]