View Source Ecto.Hashids (ecto_tablestore v0.15.1)

A custom type leverages the generated sequence integer value to encode a hashid string for the primary key, recommend to use this for the partition key (the first defined primary key).

Define :hashids type to the primary key of schema, for example:

defmodule MySchema do
  use EctoTablestore.Schema

  schema "table_name" do
    field(:id, Ecto.Hashids, primary_key: true, autogenerate: true)
  end

end

In the above case, there will try to find a schema :hashids configuration from the application environment:

config :ecto_tablestore,
  hashids: [
    {MySchema, [salt: "...", min_len: ..., alphabet: "..."]}
  ]

If the :hashids option of the application environment is not defined, there will use default options("[]") to Hashids.new/1.

We can also set the options when define the :hashids type to the primary key, for example:

field(:id, :hashids,
  primary_key: true,
  autogenerate: true
  hashids: [salt: "...", min_len: ..., alphabet: "..."]
)

Once the above :hashids options defined in the :id field of schema, there will always use them to encode a hashid, meanwhile the application runtime environment definition will not affect them.

Please see the options of Hashids.new/1 for details.