View Source ShortUUID.Prefixed (ShortUUID v3.0.0)
An Ecto parameterized type that generates prefixed ShortUUIDs.
Stores standard UUIDs in the database but presents them as prefixed ShortUUIDs
in your application (e.g., usr_F6tzXELwufrXBFtFTKsUvc).
examples
Examples
@primary_key {:id, ShortUUID.Prefixed, prefix: "usr", autogenerate: true}
@foreign_key_type ShortUUID.Prefixed
schema-helper
Schema helper
For convenience, you can use ShortUUID.Prefixed.Schema which sets up the
primary key and foreign key type automatically:
defmodule MyApp.User do
use ShortUUID.Prefixed.Schema, prefix: "usr"
schema "users" do
# ...
end
end
Link to this section Summary
Functions
Converts a prefixed ShortUUID back to a standard UUID.
Converts a prefixed ShortUUID back to a standard UUID.
Link to this section Functions
Converts a prefixed ShortUUID back to a standard UUID.
Returns {:ok, uuid} on success, :error on failure.
examples
Examples
iex> ShortUUID.Prefixed.to_uuid("usr_99dn6s7bZoVpjzYciVNgN")
{:ok, "01234567-89ab-cdef-0123-456789abcdef"}
iex> ShortUUID.Prefixed.to_uuid("invalid")
:error
Converts a prefixed ShortUUID back to a standard UUID.
Raises on invalid input.
examples
Examples
iex> ShortUUID.Prefixed.to_uuid!("usr_99dn6s7bZoVpjzYciVNgN")
"01234567-89ab-cdef-0123-456789abcdef"