ReQL command: each
Command syntax
cursor.each { ... } array.each { ... } feed.each { ... }
Description
Lazily iterate over a result set one element at a time.
RethinkDB sequences can be iterated through via the Ruby Enumerable interface; use standard Ruby commands like each
blocks to access each item in the sequence.
Example: Let’s process all the elements!
cursor = r.table('users').run(conn)
cursor.each { |doc|
process_row(doc)
}
Example: Stop the iteration prematurely and close the connection manually.
cursor = r.table('users').run(conn)
cursor.each do |doc|
ok = process_row(doc)
if not ok
cursor.close()
break
end
end
© RethinkDB contributors
Licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
https://rethinkdb.com/api/ruby/each/