0.01
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Allows performing chunked queries on DataMapper Models or Collections.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.0
~> 0.7

Runtime

 Project Readme

dm-chunked_query

Description

Allows performing chunked queries on DataMapper Models or Collections.

Features

  • Allows random-access to chunks within a query.
  • Can iterate through all chunks within a query.
  • Can be used for bulk-processing of resources.
  • Can also be used for pagination of resources.

Examples

Enumerate over all chunks, 20 resources per-chunk:

require 'dm-chunked_query'

MyModel.each_chunk(20) do |chunk|
  chunk.each do |resource|
    # ...
  end
end

Get the 5th chunk, containing 10 resources:

MyModel.all(:foo => 'bar').chunks(10)[5]

Process records in batches:

MyModel.batch(100) do |resource|
  # ...
end

Requirements

Install

$ gem install dm-chunked_query

Copyright

Copyright (c) 2011-2012 Hal Brodigan

See {file:LICENSE.txt} for details.