I need to create vertices without duplication based on a list passed to inject(), the list is very large so I need to use inject(). I tried this but it didn't work:
g.inject(["Macka", "Pedro", "Albert"]).unfold().map(
coalesce(
V().has("name", identity()),
addV("user").property("name", identity())
)
)
You can try here: https://gremlify.com/765qiupxinw
Why this doesn't work? It seems that V().has() is returning all vertices, why?
I think in this case you should use where
step and not has
:
g.inject(["Macka", "Pedro", "Albert"]).unfold().as('n').map(
coalesce(
V().where(eq('n')).by('name').by(),
addV("user").property("name", identity())
)
)
example: https://gremlify.com/06q0zxgd2uam