Class: ROM::Cassandra::Commands::Batch

Inherits:
ROM::Command
  • Object
show all
Includes:
ROM::Cassandra::Commands
Defined in:
lib/rom/cassandra/commands/batch.rb

Overview

Implements the cassandra-specific Batch command

Examples:

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

Instance Method Summary collapse

Methods included from ROM::Cassandra::Commands

#execute, included, #initialize

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ROM::Cassandra::Commands

Instance Method Details

#keyspace(name) ⇒ ROM::Cassandra::Query

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.

Parameters:

  • name (#to_s)

    The name of the keyspace

Returns:



40
41
42
# File 'lib/rom/cassandra/commands/batch.rb', line 40

def keyspace(name)
  Query.new.keyspace(name)
end