Otto v0.1.2 Otto.Table behaviour View Source

Define an ots table.

Usage

defmodule DemoTableCreate do
  use Otto.Table,
    instance: Instance1,
    table: "test_table",
    primary: [:pk1, :pk2],
    encrypt: [:enc1, :enc2],
    reserved_throughput_read: 10,
    index: [
      index_name1: [field_name1: :long, field_name2: :text],
      index_name2: [field_name1: :keyword, field_name2: :text]
    ]
end

Options

required fields

  • table - The ots table name, it should be unique in one instance.
  • primary - Primary keys list, by order, up to 4. The first key is the partition key.

optional fields

  • encrypt - Encrypt fields list, primary keys can not be encrypted.
  • index - For the new ots index funtion, used when creating search indexes. You can create multiple indexes in a single table, and field_type of the same field can be different in different indexes. These field_types are supported: [:long, :double, :boolean, :keyword, :text, :nested, :geo_point].
  • reserved_throughput_write - Integer, table write performance data.
  • reserved_throughput_read - Integer, table read performance data.
  • time_to_live - Integer, live seconds of the table data stored.
  • max_versions - Integer, max versions of table.
  • deviation_cell_version_in_sec - Integer, Prohibit writing to data with large gap with expectations.
  • stream_spec - Keyword list, define stream specs of the table, two options are avaliable: a boolean enable_stream and an integer expiration_time. For example: [enable_stream: true, expiration_time: 9999999999999]

Link to this section Summary

Functions

Create an index for your OTS table. One table can contain multiple indexes, use this function to create one at a time

Create an OTS table

Delete a search index of your OTS table

Delete your OTS table

Describe a search index of your OTS table

Describe your OTS table

List search indexes of your OTS table

Update your OTS table

Link to this section Types

Link to this section Functions

Link to this function

create_index(table, index_name) View Source
create_index(table(), String.t()) :: {:ok, any()} | {:error, any()}

Create an index for your OTS table. One table can contain multiple indexes, use this function to create one at a time.

Link to this function

create_table(table) View Source
create_table(table()) :: :ok | {:error, any()}

Create an OTS table.

You must create a table before you can interact with the table. The only parameter table is the module name of your table, the table to generate will take the options when you use Otto.Table.

Once created, the table's primary keys cannot change.

Link to this function

delete_search_index(table, index_name, opts \\ []) View Source
delete_search_index(table(), atom(), keyword()) ::
  {:ok, any()} | {:error, any()}

Delete a search index of your OTS table.

Link to this function

delete_table(table) View Source
delete_table(table()) :: :ok | {:error, any()}

Delete your OTS table.

Link to this function

describe_search_index(table, index_name, opts \\ []) View Source
describe_search_index(table(), atom(), keyword()) ::
  {:ok, any()} | {:error, any()}

Describe a search index of your OTS table.

Link to this function

describe_table(table) View Source
describe_table(table()) :: {:ok, any()} | {:error, any()}

Describe your OTS table.

It will return table_meta, reserved_throughput_details, table_options, stream_specs, shared_splits info.

Link to this function

list_search_index(table, opts \\ []) View Source
list_search_index(table(), keyword()) :: {:ok, any()} | {:error, any()}

List search indexes of your OTS table.

Link to this function

update_table(table) View Source
update_table(table()) :: :ok | {:error, any()}

Update your OTS table.

OTS table's primary cannot be changed, you can update table_options, stream_specs. All the params it takes are from your options when using Otto.Table.

Link to this section Callbacks

Link to this callback

__schema__(atom) View Source
__schema__(:fields) :: [atom()]

Link to this callback

__schema__(atom, field) View Source
__schema__(:type, field()) :: atom()