Iterate() step is used in the end of the command when creating nodes and edges through function chaining in Tinkerpop 3.3/Gremlin. What is the significance of this iterate() step? I could not find any mention of the iterate() step in the documentation explaining its features. Could someone please point me to the documentation or provide an explanation about iterate() ? Link to iterate usage can be found here.
Asked
Active
Viewed 2,422 times
1 Answers
6
iterate()
is one of the terminal steps that are used to actually execute a traversal. Without such a terminal step you are only getting back a traversal. Terminal steps like next()
or iterate()
actually execute this traversal.
iterate()
is the terminal step that can be used when you don't want to return anything from the traversal. That's why it is used in the recipes to add data to the graph.
One thing to note is that the Gremlin Console executes traversals automatically for you even when they don't end in a terminal step. This can be a bit confusing to new users.

Florian Hockmann
- 2,634
- 13
- 24
-
Do terminal steps auto-commit its own `Transaction tx`? I think I'm getting different behaviors between OrientDB and JanusGraph, but I'm not sure. – Zach May 09 '23 at 19:08
-
1If you start JanusGraph as a server (called JanusGraph Server) then it's Gremlin Server with some additions for JanusGraph and Gremlin Server handles transactions automatically: https://tinkerpop.apache.org/docs/current/reference/#considering-transactions I don't know about OrientDB though. – Florian Hockmann May 10 '23 at 06:51