View Source Electric.Client.ShapeDefinition (Electric Client v0.1.0-dev-9)

Struct for defining a shape.

iex> ShapeDefinition.new("items", where: "something = true")
{:ok, %ShapeDefinition{table: "items", where: "something = true"}}

Summary

Functions

Create a ShapeDefinition for the given table_name.

Return a string representation of the shape's table, quoted for use in API URLs.

Types

@type option() :: {:where, nil | binary()} | {:namespace, nil | binary()}
@type options() :: [option()]
@type t() :: %Electric.Client.ShapeDefinition{
  columns: [String.t(), ...] | nil,
  namespace: String.t() | nil,
  table: String.t(),
  where: nil | String.t()
}

Functions

Link to this function

new(table_name, opts \\ [])

View Source
@spec new(String.t(), options()) :: {:ok, t()} | {:error, term()}

Create a ShapeDefinition for the given table_name.

Options

  • :where - Filter the table according to the where clause. The default value is nil.

  • :namespace - The namespace the table belongs to. If nil then Postgres will use whatever schema is the default (usually public). The default value is nil.

Link to this function

new!(table_name, opts \\ [])

View Source
@spec new!(String.t(), options()) :: t() | no_return()
Link to this function

url_table_name(shape_definition)

View Source
@spec url_table_name(t()) :: String.t()

Return a string representation of the shape's table, quoted for use in API URLs.

iex> ShapeDefinition.url_table_name(ShapeDefinition.new!("my_table"))
"my_table"

iex> ShapeDefinition.url_table_name(ShapeDefinition.new!("my_table", namespace: "my_app"))
"my_app.my_table"

iex> ShapeDefinition.url_table_name(ShapeDefinition.new!("my table", namespace: "my app"))
"%22my app%22.%22my table%22"