Back to top

ReQL command: next

Command syntax[timeout, unit])


Get the next element in the result.

If the optional arguments are supplied, waits up to the specified number of seconds for data to be available before raising TimeoutException.

Calling next the first time on a result provides the first element of the result. If the data set is exhausted (e.g., you have retrieved all the documents in a table), a NoSuchElementException error will be raised when next is called.

Example: Retrieve the next element.

Result<Object> result = r.table("superheroes").run(conn);
Object doc =;

Example: Retrieve the next element on a changefeed, waiting up to five seconds.

Result<Object> result = r.table("superheroes").changes().run(conn);
Object doc =, TimeUnit.SECONDS);

Note: RethinkDB results can be iterated through via the Java Iterable and Iterator interfaces. The canonical way to retrieve all the results is to use a for loop or toList.

Get more help

Couldn't find what you were looking for?