duffrey
duffrey
ATApache TinkerPop
Created by duffrey on 9/11/2023 in #questions
Trying to find a Vertex using a variable injected earlier in the traversal
I am trying to add a series of vertices and edges to an existing graph. The newly created Vertex will be the to Vertex. From business logic, I will know the ID of the from Vertex for the new Edge . I am able to create the new Vertex without any issue, but when I am having trouble grabbing the from Vertex to create the edge. Is there a way to do this/what am I doing wrong?
g.inject(["myID": "2", "parentID": "1", "properties": ["key1":"value1"]]).
addV("MyVertex").as("newVertex").
property(id, select("myID")).
sideEffect(
select("properties").unfold().as("kv")
select("newVertex").
property(
select("kv").by(keys),
select("kv").by(values),
)
).
AddE("MyEdge").to("newVertex").from(V(select("parentID")))
g.inject(["myID": "2", "parentID": "1", "properties": ["key1":"value1"]]).
addV("MyVertex").as("newVertex").
property(id, select("myID")).
sideEffect(
select("properties").unfold().as("kv")
select("newVertex").
property(
select("kv").by(keys),
select("kv").by(values),
)
).
AddE("MyEdge").to("newVertex").from(V(select("parentID")))
8 replies