to_a
ReQL command: to_a
Command syntax
cursor.to_a()
Description
Retrieve all results as an array.
RethinkDB sequences can be iterated through via the Ruby Enumerable interface; to coerce a cursor into an array, use the Ruby to_a()
command.
Example: For small result sets it may be more convenient to process them at once as an array.
cursor = r.table('users').run() users = cursor.to_a() process_results(users)
The equivalent query with an each
block would be:
cursor = r.table('users').run() cursor.each { |doc| process_results(doc) }
Note: Because a