UUIDv7.Type (UUIDv7 v0.6.0)
View SourceEcto type for UUIDv7.
Summary
Ecto.Type Functions
Casts either a string in the canonical, human-readable UUID format or a 16-byte binary to a UUID in its canonical, human-readable UUID format.
Same as cast/1
but raises Ecto.CastError
on invalid arguments.
Converts a string representing a UUID into a raw binary.
Same as dump/1
but raises Ecto.ArgumentError
on invalid arguments.
Callback implementation for Ecto.Type.embed_as/1
.
Callback implementation for Ecto.Type.equal?/2
.
Converts a binary UUID into a string.
Same as load/1
but raises Ecto.ArgumentError
on invalid arguments.
Types
@type raw() :: UUIDv7.raw()
@type t() :: UUIDv7.t()
Ecto.Type Functions
Casts either a string in the canonical, human-readable UUID format or a 16-byte binary to a UUID in its canonical, human-readable UUID format.
If uuid
is neither of these, :error
will be returned.
Since both binaries and strings are represent as binaries, this means some strings you may not expect are actually also valid UUIDs in their binary form and so will be casted into their string form.
Examples
iex> raw = <<1, 141, 236, 237, 26, 200, 116, 82, 179, 112, 220, 56, 9, 179, 208, 93>>
iex> UUIDv7.cast(raw)
{:ok, "018deced-1ac8-7452-b370-dc3809b3d05d"}
iex> UUIDv7.cast("018deced-1ac8-7452-b370-dc3809b3d05d")
{:ok, "018deced-1ac8-7452-b370-dc3809b3d05d"}
iex> UUIDv7.cast("warehouse worker")
{:ok, "77617265-686f-7573-6520-776f726b6572"}
Same as cast/1
but raises Ecto.CastError
on invalid arguments.
Converts a string representing a UUID into a raw binary.
Same as dump/1
but raises Ecto.ArgumentError
on invalid arguments.
Callback implementation for Ecto.Type.embed_as/1
.
Callback implementation for Ecto.Type.equal?/2
.
Converts a binary UUID into a string.
Same as load/1
but raises Ecto.ArgumentError
on invalid arguments.