Class: Cequel::Schema::CreateTableDSL

Inherits:
BasicObject
Extended by:
Util::Forwardable
Defined in:
lib/cequel/schema/create_table_dsl.rb

Overview

Implements a DSL that can be used to define a table schema

See Also:

Since:

  • 1.0.0

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Util::Forwardable

delegate

Constructor Details

#initialize(table) ⇒ CreateTableDSL

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of CreateTableDSL.

Parameters:

  • table (Table)

    table to apply directives to

Since:

  • 1.0.0



31
32
33
# File 'lib/cequel/schema/create_table_dsl.rb', line 31

def initialize(table)
  @table = table
end

Class Method Details

.apply(table) { ... } ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Evaluate block in the context of this DSL, and apply directives to table

Parameters:

  • table (Table)

    a table

Yields:

  • block evaluated in the context of the create table DSL

Since:

  • 1.0.0



21
22
23
24
# File 'lib/cequel/schema/create_table_dsl.rb', line 21

def self.apply(table, &block)
  dsl = new(table)
  dsl.instance_eval(&block)
end

Instance Method Details

#column(name, type, options = {}) ⇒ void

This method returns an undefined value.

Define a data column on the table

Parameters:

  • name (Symbol)

    name of the column

  • type (Type)

    type for the column

  • options (Options) (defaults to: {})

    options for the column

Options Hash (options):

  • :index (Boolean, Symbol) — default: nil

    name of a secondary index to apply to the column, or true to infer an index name by convention



51
# File 'lib/cequel/schema/create_table_dsl.rb', line 51

def_delegator :@table, :add_data_column, :column

#compact_storagevoid

This method returns an undefined value.

Direct that this table use “compact storage”. This is primarily useful for backwards compatibility with legacy CQL2 table schemas.

Since:

  • 1.0.0



83
84
85
# File 'lib/cequel/schema/create_table_dsl.rb', line 83

def compact_storage
  @table.compact_storage = true
end

#key(name, type, clustering_order = nil) ⇒ void

This method returns an undefined value.

Define a key column. If this is the first key column defined, it will be a partition key; otherwise, it will be a clustering column.

Parameters:

  • name (Symbol)

    the name of the column

  • type (Symbol, Type)

    the type for the column

  • clustering_order (:asc, :desc) (defaults to: nil)

    whether rows should be in ascending or descending order by this column. Only meaningful for clustering columns.

See Also:

  • #add_partition_key


45
# File 'lib/cequel/schema/create_table_dsl.rb', line 45

def_delegator :@table, :add_key, :key

#list(name, type) ⇒ void

This method returns an undefined value.

Define a list column on the table

Parameters:

  • name (Symbol)

    name of the list

  • type (Symbol, Type)

    type of the list’s elements

See Also:



57
# File 'lib/cequel/schema/create_table_dsl.rb', line 57

def_delegator :@table, :add_list, :list

#map(name, key_type, value_type) ⇒ void

This method returns an undefined value.

Define a map column on the table

Parameters:

  • name (Symbol)

    name of the set

  • key_type (Symbol, Type)

    type of the map’s keys

  • value_type (Symbol, Type)

    type of the map’s values

See Also:



69
# File 'lib/cequel/schema/create_table_dsl.rb', line 69

def_delegator :@table, :add_map, :map

#partition_key(name, type) ⇒ void

This method returns an undefined value.

Define a partition key for the table

Parameters:

  • name (Symbol)

    the name of the column

  • type (Symbol, Type)

    the type for the column



39
# File 'lib/cequel/schema/create_table_dsl.rb', line 39

def_delegator :@table, :add_partition_key, :partition_key

#set(name, type) ⇒ void

This method returns an undefined value.

Define a set column on the table

Parameters:

  • name (Symbol)

    name of the set

  • type (Symbol, Type)

    type of the set’s elements

See Also:



63
# File 'lib/cequel/schema/create_table_dsl.rb', line 63

def_delegator :@table, :add_set, :set

#with(name, value) ⇒ void

This method returns an undefined value.

Define a storage property for the table

Parameters:

  • name (Symbol)

    name of the property

  • value

    value for the property

See Also:



75
# File 'lib/cequel/schema/create_table_dsl.rb', line 75

def_delegator :@table, :add_property, :with