rails - find_each, find_by_batch
访问量: 472
refer to:
find_each
用法很简单,就是跟 Model.where.each do ... 一样的。
find_by_batch:
循环的时候,里面是 一个model array.
Block.where('id < 30').find_in_batches(batch_size: 10) do |g| g.each {|b| puts b.id} end;
访问量: 472
refer to:
用法很简单,就是跟 Model.where.each do ... 一样的。
循环的时候,里面是 一个model array.
Block.where('id < 30').find_in_batches(batch_size: 10) do |g| g.each {|b| puts b.id} end;