View Source Electric.Client.ShapeDefinition (Electric Client v0.2.5)
Struct for defining a shape.
iex> ShapeDefinition.new("items", where: "something = true")
{:ok, %ShapeDefinition{table: "items", where: "something = true"}}
Summary
Functions
Tests if two %ShapeDefinition{}
instances are equal, ignoring the parser
setting.
Create a ShapeDefinition
for the given table_name
.
Return a string representation of the shape's table, quoted for use in API URLs.
Types
Functions
Tests if two %ShapeDefinition{}
instances are equal, ignoring the parser
setting.
Example
iex> {:ok, shape1} = Electric.Client.ShapeDefinition.new("items")
iex> {:ok, shape2} = Electric.Client.ShapeDefinition.new("items")
iex> Electric.Client.ShapeDefinition.matches?(shape1, shape2)
true
iex> {:ok, shape3} = Electric.Client.ShapeDefinition.new("items", where: "something = 'here'")
iex> Electric.Client.ShapeDefinition.matches?(shape1, shape3)
false
Create a ShapeDefinition
for the given table_name
.
Options
:where
- Filter the table according to the where clause. The default value isnil
.:columns
- List of columns to include in the shape. Must include all primary keys. Ifnil
this is equivalent to all columns (SELECT *
) The default value isnil
.:namespace
- The namespace the table belongs to. Ifnil
then Postgres will use whatever schema is the default (usuallypublic
). The default value isnil
.:parser
- A{module, args}
tuple specifying theElectric.Client.ValueMapper
implementation to use for mapping values from the sync stream into Elixir terms. The default value is{Electric.Client.ValueMapper, []}
.
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"))
~s["my app"."my table"]