Skip to content

Commit

Permalink
Merge pull request #416 from TheSmartnik/improvement/use-batch-delete…
Browse files Browse the repository at this point in the history
…-item-in-truncate

Use #batch_delete_item in #truncate
  • Loading branch information
andrykonchin committed Feb 28, 2020
2 parents c2dc6b3 + 3682025 commit ed482f0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/dynamoid/adapter_plugin/aws_sdk_v3.rb
Expand Up @@ -544,11 +544,11 @@ def truncate(table_name)
hk = table.hash_key
rk = table.range_key

scan(table_name, {}, {}).flat_map { |i| i }.each do |attributes|
opts = {}
opts[:range_key] = attributes[rk.to_sym] if rk
delete_item(table_name, attributes[hk], opts)
ids = scan(table_name, {}, {}).flat_map { |i| i }.map do |attributes|
rk ? [attributes[hk], attributes[rk.to_sym]] : attributes[hk]
end

batch_delete_item(table_name => ids)
end

def count(table_name)
Expand Down

0 comments on commit ed482f0

Please sign in to comment.