| layout | api-command | ||||||
|---|---|---|---|---|---|---|---|
| language | Java | ||||||
| permalink | api/java/to_array/ | ||||||
| command | toList | ||||||
| related_commands |
|
{% apibody %} result.toList() → List {% endapibody %}
Retrieve all results from a result as a list.
RethinkDB results can be iterated through via the Java Iterable and Iterator interfaces; to coerce a result into a list, use toList.
Example: For small result sets it may be more convenient to process them at once as a list.
processResults(r.table("users").run(conn).toList());The equivalent query with a for loop would be:
try(Result<Object> result = r.table("users").run(conn)) {
for (Object doc : result) {
processResult(doc);
}
}Note: Because a feed is a result that never terminates, using list with a feed will never return. Use for or next instead. See the changes command for more information on feeds.