im using nodejs
, neo4j
with node-neo4j
and trying to put multiple gremlin
command together
and im stuck with this problem
if i execute the commands one after another like
x = [] as Set
y = [] as Set
g.v(id1).both('friend').aggregate(x)
g.v(id2).both('friend').aggregate(y)
x.retainAll(y);
x
it works fine and a list of nodes is returned
on the other hand if i write it like
x = [] as Set;y = [] as Set;g.v(id1).both('friend').aggregate(x);g.v(id2).both(
'friend').aggregate(y);x.retainAll(y);x
nothing is returned
read an answer here which says that
if your last command is not an iterator then you will have to manually iterate of the sequence
but dont know how to apply this in my case.
oops!
i was missing a very simple thing .iterate()
this command now works
x = [] as Set;y = [] as Set;g.v(id1).both('friend').aggregate(x).iterate();g.v(id2).both('friend').aggregate(y).iterate();x.retainAll(y);x