【发布时间】:2019-06-13 10:15:31
【问题描述】:
如果边缘尚不存在,我会找到以下代码来创建边缘。
g.V().hasLabel("V1")
.has("userId", userId).as("a")
.V().hasLabel("V1").has("userId", userId2)
.coalesce(
bothE("link").where(outV().as("a")),
addE("link").from("a")
)
它工作正常,但如果顶点和边在 1 个查询中不存在,我想创建它们。
我用新图尝试以下代码,它只是创建新顶点但它们之间没有关系。
g.V().hasLabel("V1")
.has("userId", userId).fold()
.coalesce(
unfold(),
addV("V1").property("userId", userId1)
).as("a")
.V().hasLabel("V1").has("userId", userId2).fold()
.coalesce(
unfold(),
addV("V1").property("userId", userId2)
)
.coalesce(
bothE("link").where(outV().as("a")),
addE("link").from("a")
)
【问题讨论】:
标签: graph gremlin janusgraph