Ecto.Nanoid (ecto_identifier v0.2.0) View Source
Custom type that can auto-generate nanoids.
Usage
defmodule Post do
use Ecto.Schema
alias Ecto.Nanoid
schema "posts" do
field(:number, Ecto.Nanoid, autogenerate: true)
field(:data, :string)
end
endIn your migrations for the posts table,
create table(:posts) do
add :number, :string
add :data, :string
end
Link to this section Summary
Functions
Delegates generation of the field to Nanoid.generate/0.
Callback implementation for Ecto.Type.cast/1.
Callback implementation for Ecto.Type.dump/1.
Callback implementation for Ecto.Type.embed_as/1.
Callback implementation for Ecto.Type.equal?/2.
Callback implementation for Ecto.Type.load/1.
Callback implementation for Ecto.Type.type/0.
Link to this section Functions
Specs
autogenerate() :: String.t()
Delegates generation of the field to Nanoid.generate/0.
To change the default nanoid size and alphabet, use config.exs as indicated
here.
Callback implementation for Ecto.Type.cast/1.
Callback implementation for Ecto.Type.dump/1.
Callback implementation for Ecto.Type.embed_as/1.
Callback implementation for Ecto.Type.equal?/2.
Callback implementation for Ecto.Type.load/1.
Callback implementation for Ecto.Type.type/0.