module Cequel::Record::BulkWrites
This module implements bulk update and delete functionality for classes that expose a collection of result rows.
@abstract Including modules must implement `key_attributes_for_each_row`,
which should yield successive fully-specified key attributes for each result row.
@since 1.0.0
Public Instance Methods
delete_all()
click to toggle source
Delete all matched records without executing callbacks
@return [void]
# File lib/cequel/record/bulk_writes.rb, line 30 def delete_all each_data_set { |data_set| data_set.delete } end
destroy_all()
click to toggle source
Destroy all matched records, executing destroy callbacks for each record.
@return [void]
# File lib/cequel/record/bulk_writes.rb, line 40 def destroy_all each { |record| record.destroy } end
update_all(attributes)
click to toggle source
Update all matched records with the given column values, without executing callbacks.
@param attributes [Hash] map of column names to values @return [void]
# File lib/cequel/record/bulk_writes.rb, line 21 def update_all(attributes) each_data_set { |data_set| data_set.update(attributes) } end
Private Instance Methods
each_data_set() { |where| ... }
click to toggle source
# File lib/cequel/record/bulk_writes.rb, line 46 def each_data_set key_attributes_for_each_row.each_slice(100) do |batch| connection.batch(unlogged: true) do batch.each { |key_attributes| yield table.where(key_attributes) } end end end