Alchemy Table v0.1.2 AlchemyTable.Schema View Source
Allows the creation of typed Bigtable schemas.
Examples
iex> defmodule SchemaExample do
...> use AlchemyTable.Schema
...> @update_patterns ["family_a.column_a"]
...> row :entity do
...> family :family_a do
...> column(:column_a, :integer)
...> column(:column_b, :boolean)
...> end
...> family :family_b do
...> column(:column_a, :map)
...> column(:column_b, :list)
...> end
...> end
...> end
iex> SchemaExample.type() |> Map.from_struct()
%{
family_a: %{
column_a: :integer,
column_b: :boolean
},
family_b: %{
column_a: :map,
column_b: :list
}
}
Link to this section Summary
Functions
Defines a column inside a Bigtable.Schema.family/2
definition
Defines a column family inside a Bigtable.Schema.row/2
definition
Defines a schema to be used when reading and mutating Bigtable rows
Defines a type that can be used as the value for a Bigtable.Schema.column/2
definition
Link to this section Functions
column(key, value) View Source (macro)
Defines a column inside a Bigtable.Schema.family/2
definition.
The first argument is an atom that will define the column's name.
The second argument defines the column's type and should be one of:
:integer
:float
:boolean
:string
:map
:list
If the column value is defined as either :map
or :list
, the value will be JSON encoded during mutations and decoded during reads.
family(name, list) View Source (macro)
Defines a column family inside a Bigtable.Schema.row/2
definition.
The name of the family should be provided to the macro as an atom.
The block of the macro should only contain Bigtable.Schema.column/2
definitions.
row(name, list) View Source (macro)
Defines a schema to be used when reading and mutating Bigtable rows.
Examples
defmodule Schema do
use Bigtable.Schema
row :entity do
family :family_a do
column(:column_a, :string)
end
family :family_b do
column(:column_a, :integer)
column(:column_b, :boolean)
end
end
end
type(list) View Source (macro)
Defines a type that can be used as the value for a Bigtable.Schema.column/2
definition.
Examples
defmodule Type do
use Bigtable.Schema
type do
column(:a, :integer)
column(:b, :string)
end
end
defmodule Schema do
use Bigtable.Schema
row :entity do
family :family do
column(:column, Type)
end
end
end