Class: Cequel::Schema::CreateTableDSL

Inherits:
BasicObject
Extended by:
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

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



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

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



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

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



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

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



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

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


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

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:



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

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:



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

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



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

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:



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

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:



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

def_delegator :@table, :add_property, :with