【发布时间】:2019-10-31 09:53:11
【问题描述】:
我正在尝试添加一个顶点,该顶点将链接到另一个顶点,在它们的边缘之间具有条件属性值。
到目前为止,这是我想出的: - 这运行没有错误,但我无法得到任何结果。
g.V().has('label', 'product')
.has('id', 'product1')
.outE('has_image')
.has('primary', true)
.inV()
.choose(fold().coalesce(unfold().values('public_url'), constant('x')).is(neq('x')))
.option(true,
addV('image')
.property('description', '')
.property('created_at', '2019-10-31 09:08:15')
.property('updated_at', '2019-10-31 09:08:15')
.property('pk', 'f920a210-fbbd-11e9-bed6-b9a9c92913ef')
.property('path', 'product_images/87wfMABXBodgXL1O4aIf6BcMMG47ueUztjNCkGxP.png')
.V()
.hasLabel('product')
.has('id', 'product1')
.addE('has_image')
.property('primary', false))
.option(false,
addV('image')
.property('description', '')
.property('created_at', '2019-10-31 09:08:15')
.property('updated_at', '2019-10-31 09:08:15')
.property('pk', 'f920a930-fbbd-11e9-b444-8bccc55453b9')
.property('path', 'product_images/87wfMABXBodgXL1O4aIf6BcMMG47ueUztjNCkGxP.png')
.V()
.hasLabel('product')
.has('id', 'product1')
.addE('has_image')
.property('primary', true))
我在这里所做的是试图在image 顶点和product 顶点之间设置新添加边的primary 属性,具体取决于product 是否已经连接到image,其中edge 已经将 primary 设置为 true。
如果product 已经有一个带有边缘属性的image:primary:true,那么将链接到产品的新添加的图像应该具有带有属性primary:false 的边缘
种子 azure graphdb:
//add product vertex
g.addV('product').property(id, 'product1').property('pk', 'product1')
//add image vertex
g.addV('image').property(id, 'image1').property('public_url', 'url_1').property('pk', 'image1');
//link products to images
g.V('product1').addE('has_image').to(V('image1')).property('primary', true)
【问题讨论】:
标签: graph-databases gremlin azure-cosmosdb-gremlinapi