dynamoid

https://github.com/veraticus/dynamoid

Ruby ORM for Amazon's DynamoDB

EachBatch::ClassMethods#each_batch

Iterates over the rows in a relation in batches, similar to Rails'
`in_batches` but in a more efficient way.

Unlike `in_batches` provided by Rails this method does not support a
custom start/end range, nor does it provide support for the `load:`
keyword argument.

This method will yield an ActiveRecord::Relation to the supplied block, or
return an Enumerator if no block is given.

Example:

    User.each_batch do |relation|
      relation.update_all(updated_at: Time.now)
    end

The supplied block is also passed an optional batch index:

    User.each_batch do |relation, index|
      puts index # => 1, 2, 3, ...
    end

You can also specify an alternative column to use for ordering the rows:

    User.each_batch(column: :created_at) do |relation|
      ...
    end

This will produce SQL queries along the lines of:

    User Load (0.7ms)  SELECT  "users"."id" FROM "users" WHERE ("users"."id" >= 41654)  ORDER BY "users"."id" ASC LIMIT 1 OFFSET 1000
      (0.7ms)  SELECT COUNT(*) FROM "users" WHERE ("users"."id" >= 41654) AND ("users"."id" < 42687)

of - The number of rows to retrieve per batch.
column - The column to use for ordering the batches.

Source | Google | Stack overflow

Edit

git clone [email protected]:veraticus/dynamoid.git

cd dynamoid

open

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-EachBatch--ClassMethods-each_batch-for-pr


# Commit to git

git add git commit -m "better docs for EachBatch::ClassMethods#each_batch"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-EachBatch--ClassMethods-each_batch-for-pr

hub pull-request


# Celebrate!