Packages
exandra
0.16.0
1.1.0
1.0.0
0.16.0
0.15.0
0.14.0
0.13.0
0.12.0
0.11.0
0.10.3
0.10.2
0.10.1
0.10.1-rc.5
0.10.0
0.10.0-rc.5
0.10.0-rc.4
0.10.0-rc.3
0.10.0-rc.2
0.10.0-rc.1
0.9.1
0.9.0
0.8.1
0.8.0
0.7.5
0.6.5
0.6.4
0.6.3
0.6.2
0.6.1
0.6.0
0.5.1
0.5.0
0.4.1
0.4.0
0.3.1
0.3.0
0.2.1
0.2.0
0.1.16
0.1.15
0.1.14
0.1.13
0.1.12
0.1.11
0.1.10
Exandra is an Elixir library that brings the power of Scylla/Cassandra to Ecto.
Current section
Files
Jump to
Current section
Files
lib/exandra/counter.ex
defmodule Exandra.Counter do
@moduledoc """
`Ecto.Type` for counters.
## Examples
schema "page_views" do
field :url, :string
field :views, Exandra.Counter
end
"""
@typedoc """
The type for an Exandra counter.
"""
@type t() :: integer()
use Ecto.Type
@impl Ecto.Type
def type, do: :counter
@impl Ecto.Type
def cast(val) when is_integer(val) do
{:ok, val}
end
@impl Ecto.Type
def load(val) do
{:ok, val}
end
@impl Ecto.Type
def dump(val) do
{:ok, val}
end
end