Module: Cassie::Statements::Statement::Selection::ClassMethods

Defined in:
lib/cassie/statements/statement/selection.rb

Instance Method Summary collapse

Instance Method Details

#count(selector = '*') ⇒ Object

DSL to wrap a selector in the COUNT CQL, used to select the aggregation of the number of rows instead of the value in each row



86
87
88
# File 'lib/cassie/statements/statement/selection.rb', line 86

def count(selector='*')
  "COUNT(#{selector})"
end

#select(column, opts = {}) ⇒ String

DSL to add a column to be ruturned for each row in the query results

Parameters:

  • column (String, Symbol)

    The column name in the CQL schmea to return

  • opts (Hash) (defaults to: {})

    options for the selector

Options Hash (opts):

  • :as (String)

    The identifier to use for the field when returned in the result if different than the column name

Returns:

  • (String)

    the current enumeration of selectors



56
57
58
59
60
# File 'lib/cassie/statements/statement/selection.rb', line 56

def select(column, opts={})
  column = column.to_s
  column += " AS #{opts[:as]}" if opts[:as]
  selectors << column
end

#select_from(table) {|_self| ... } ⇒ void

This method returns an undefined value.

DSL to set the statement type and table for selection

Parameters:

  • table (String, Symbol)

    The table to taret for the select statement

Yields:

  • (_self)

Yield Parameters:



44
45
46
47
48
49
# File 'lib/cassie/statements/statement/selection.rb', line 44

def select_from(table)
  self.table = table
  self.type = :select

  yield(self) if block_given?
end

#selectorsArray<String>

The enumeration of selectors for use in the statement

Returns:

  • (Array<String>)


64
65
66
# File 'lib/cassie/statements/statement/selection.rb', line 64

def selectors
  @selectors ||= []
end

#ttl(selector) ⇒ Object

DSL to wrap a selector in the TTL CQL, used to select the time until the field will be tombstoned, instead of the value itself



79
80
81
# File 'lib/cassie/statements/statement/selection.rb', line 79

def ttl(selector)
  "TTL(#{selector})"
end

#write_time(selector) ⇒ Object Also known as: writetime

DSL to wrap a selector in the WRITETIME CQL, used to select the time the field was written instead of the value itself



71
72
73
# File 'lib/cassie/statements/statement/selection.rb', line 71

def write_time(selector)
  "WRITETIME(#{selector})"
end