Method: Sequel::Dataset#where_each
- Defined in:
- lib/sequel/dataset/actions.rb
#where_each(cond, &block) ⇒ Object
Iterate over all rows matching the given filter condition, yielding each row to the given block. Basically the same as where(cond).each(&block), except it can be optimized to not create an intermediate dataset.
DB[:table].where_each(id: [1,2,3]){|row| p row}
# SELECT * FROM table WHERE (id IN (1, 2, 3))
1050 1051 1052 1053 1054 1055 1056 |
# File 'lib/sequel/dataset/actions.rb', line 1050 def where_each(cond, &block) if loader = _where_loader([cond], nil) loader.each(filter_expr(cond), &block) else where(cond).each(&block) end end |