Refine.FacetsTable (Refine v0.4.0)

Copy Markdown

Facets table functions.

Documentation

Summary

Types

create_facets_table_return()

@type create_facets_table_return() ::
  {:ok, String.t()}
  | {:error, :column_not_found, String.t()}
  | {:error, :identity_column_already_exists, String.t()}
  | {:error, :identity_column_invalid_type, String.t()}
  | {:error, :identity_column_not_found, String.t()}
  | {:error, :invalid_table_name, String.t()}
  | {:error, :table_names_not_distinct}
  | {:error, :facets_table_exists, String.t()}
  | {:error, Exception.t()}

database_options()

@type database_options() :: [
  {:repo, repo()} | {:otp_app, atom()} | postgrex_options()
]

facet_config()

@type facet_config() :: %{
  facet_label: String.t() | nil,
  facet_name: String.t(),
  join_table: String.t() | nil,
  label_column: String.t() | nil,
  label_path: String.t() | nil,
  value_column: String.t() | nil,
  value_path: String.t() | nil,
  width_bucket: [integer() | float()] | nil
}

facet_configs()

@type facet_configs() :: [facet_config()]

facets_table_config()

@type facets_table_config() ::
  %{
    add_identity_column_if_not_exists: boolean() | nil,
    facets_table: String.t(),
    facets: facet_configs(),
    identity_column: String.t(),
    joins: [join_spec()] | nil,
    roaringbitmap_type: String.t() | nil,
    source_table: String.t()
  }
  | keyword()

join_spec()

@type join_spec() :: %{
  table: String.t(),
  match: String.t(),
  to: String.t(),
  where: String.t() | nil
}

join_triggers()

@type join_triggers() :: %{
  required(String.t()) => %{
    trigger: String.t(),
    trigger_fn: String.t(),
    delete_trigger: String.t()
  }
}

postgrex_options()

@type postgrex_options() :: [timeout: integer() | :infinity, log: boolean()]

repo()

@type repo() :: module()

table_columns()

@type table_columns() :: [Sublimate.TableColumnData.t()]

Functions

create_facets_table(config, opts \\ [])

@spec create_facets_table(facets_table_config(), database_options()) ::
  create_facets_table_return()

See: Refine.create_facets_table/2.

create_facets_table_if_not_exists(config, opts \\ [])

@spec create_facets_table_if_not_exists(
  facets_table_config(),
  database_options()
) :: create_facets_table_return()

See: Refine.create_facets_table_if_not_exists/2.

drop_facets_table(config, opts \\ [])

@spec drop_facets_table(facets_table_config(), database_options()) ::
  {:ok, String.t()} | {:error, :table_not_found} | {:error, Exception.t()}

See: Refine.drop_facets_table/2.