ReQL command: next
Command syntax
result.next([timeout, unit])
Description
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 = result.next();
Example: Retrieve the next element on a changefeed, waiting up to five seconds.
Result<Object> result = r.table("superheroes").changes().run(conn);
Object doc = result.next(5L, 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.
© RethinkDB contributors
Licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
https://rethinkdb.com/api/java/next/