Skip to content

Commit

Permalink
add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tycooon committed Jul 3, 2024
1 parent f728eb8 commit 8e30237
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/umbrellio_utils/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ def each_record(dataset, primary_key: nil, **options, &block)
end
end

# Iterates over a dataset and yields batches of primary keys.
# First, a temporary table is created and populated with dataset primary keys.
# After that, a batch of rows is deleted from the temp table on each iteration
# and gets yielded to the caller.
# @option [Integer] page_size max size of each yielded PK batch
# @option [Integer] sleep interval to sleep between each iteration
# @option [Array] primary_key custom primary key to use for dataset
# @option [Symbol, String] temp_table_name custom name for temporary table,
# table is reused if already exists
def with_temp_table(
dataset,
page_size: 1_000,
Expand Down

0 comments on commit 8e30237

Please sign in to comment.