UUID.Ecto.Type behaviour (UUID v1.6.3) View Source
Ecto UUID type.
Link to this section Summary
Functions
Used to create a normal Ecto.Type.
Casts to UUID.
Same as cast/1
but raises Ecto.CastError
on invalid arguments.
Converts a string representing a UUID into a binary.
Callback implementation for Ecto.ParameterizedType.embed_as/2
.
Converts a binary UUID into a string.
Link to this section Types
Specs
params() :: {uuid_type(), uuid_type_args()}
Specs
uuid_type() :: :uuid1 | :uuid3 | :uuid4 | :uuid5 | :uuid6
Specs
uuid_type_args() :: [term()]
Link to this section Functions
Used to create a normal Ecto.Type.
Defining a UUID Ecto type
defmodule Foo.Types.UUID6 do
use UUID.Ecto.Type,
type: :uuid6,
node_type: :random_bytes
end
Using
defmodule Foo.Bar do
use Ecto.Schema
alias Foo.Types.UUID6
@primary_key {:id, UUID6, autogenerate: true}
schema "foo" do
field :bar_id, UUID6
end
end
Specs
Casts to UUID.
Specs
Same as cast/1
but raises Ecto.CastError
on invalid arguments.
Specs
Converts a string representing a UUID into a binary.
Callback implementation for Ecto.ParameterizedType.embed_as/2
.
Specs
Converts a binary UUID into a string.
Link to this section Callbacks
Specs
bingenerate() :: UUID.raw()
Generates a UUID in the binary format.
Specs
Generates a UUID.