cursor.toList()
Retrieve all results from a cursor as a list.
RethinkDB cursors can be iterated through via the Java Iterable and Iterator interfaces; to coerce a cursor into a list, use toList.
Example: For small result sets it may be more convenient to process them at once as a list.
Cursor cursor = r.table("users").run(conn);
List users = cursor.toList();
processResults(users);
The equivalent query with a for loop would be:
Cursor cursor = r.table("users").run(conn);
for (Object doc : cursor) {
processResults(doc);
}
Note: Because a feed is a cursor 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.
Couldn't find what you were looking for?
© RethinkDB contributors
Licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
https://rethinkdb.com/api/java/to_array/