class ROM::Cassandra::Commands::Batch

Implements the cassandra-specific Batch command

@example

class Batch < ROM::Cassandra::Batch
  relation :items
  register_as :batch

  def execute
    super {
      self
        .add(keyspace(:domain).table(:items).delete.where(id: 1))
        .add("INSERT INTO logs.items (id, text) VALUES (1, 'deleted');")
    }
  end
end

rom.command(:users).batch.call

@api public

Public Instance Methods

keyspace(name) click to toggle source

Returns the keyspace context for lazy queries.

The method can be used within a block of [#execute] to prepare commands for adding to the batch.

@param [#to_s] name The name of the keyspace

@return [ROM::Cassandra::Query]

# File lib/rom/cassandra/commands/batch.rb, line 40
def keyspace(name)
  Query.new.keyspace(name)
end

Private Instance Methods

restriction() click to toggle source
# File lib/rom/cassandra/commands/batch.rb, line 46
def restriction
  :batch_query
end