Class: Cql::Model::Query::MutationStatement

Inherits:
Statement
  • Object
show all
Defined in:
lib/cql/model/query/mutation_statement.rb

Overview

Common parent to InsertStatement and UpdateStatment provide helpers for managing common DSL settings

Direct Known Subclasses

InsertStatement, UpdateStatement

Instance Method Summary collapse

Methods inherited from Statement

#consistency, #to_s

Constructor Details

#initialize(klass, client = nil) ⇒ MutationStatement

Instantiate statement

Parameters:

  • klass (Class)
  • CQL (Cql::Client)

    client used to execute statement



11
12
13
14
15
16
# File 'lib/cql/model/query/mutation_statement.rb', line 11

def initialize(klass, client=nil)
  super(klass, client)
  @values    = nil
  @ttl       = nil
  @timestamp = nil
end

Instance Method Details

#executetrue

Execute this statement on the CQL client connection INSERT statements do not return a result

Returns:

  • (true)

    always returns true



40
41
42
43
# File 'lib/cql/model/query/mutation_statement.rb', line 40

def execute
  @client.execute(to_s)
  true
end

#timestamp(timestamp_value) ⇒ Object

DSL for setting timestamp value

Parameters:

  • timestamp_value (Fixnum|String)

    (number of milliseconds since epoch or ISO 8601 date time value)

Raises:

  • (ArgumentError)


30
31
32
33
34
# File 'lib/cql/model/query/mutation_statement.rb', line 30

def timestamp(timestamp_value)
  raise ArgumentError, "Cannot specify timestamp twice" unless @timestamp.nil?
  @timestamp = timestamp_value
  self
end

#ttl(ttl_value) ⇒ Object

DSL for setting TTL value

Parameters:

  • ttl_value (Fixnum)

    TTL value in seconds

Raises:

  • (ArgumentError)


21
22
23
24
25
# File 'lib/cql/model/query/mutation_statement.rb', line 21

def ttl(ttl_value)
  raise ArgumentError, "Cannot specify TTL twice" unless @ttl.nil?
  @ttl = ttl_value
  self
end